diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index b7d61674fd8d4..aedaeda0e5b2c 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -117,30 +117,6 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -183,8 +159,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -262,7 +236,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c4c3d03ee97ca..e696b4774d18d 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -110,27 +110,37 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -272,7 +282,7 @@ print $langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 0768ee01bf898..cec7fbdced48b 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -114,30 +114,6 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; - $sql1.= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -180,8 +156,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -253,7 +227,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index e00b4527818b4..28a44d23a5edd 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -43,7 +43,7 @@ $langs->load("trips"); $langs->load("productbatch"); -$account_parent = GETPOST('account_parent'); +$account_parent = GETPOST('account_parent','int'); $changeaccount = GETPOST('changeaccount'); // Search Getpost $search_expensereport = GETPOST('search_expensereport', 'alpha'); @@ -103,27 +103,36 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 .= " SET erd.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -246,7 +255,7 @@ print $langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1425dde58f7cb..e9935fc8d7818 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -115,31 +115,9 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.= ")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } + /* * View */ @@ -178,8 +156,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -252,7 +228,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print '
'; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index af9d82e5056e4..6ad8731a4157d 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -111,27 +111,36 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -269,7 +278,7 @@ print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 56eb8beeca725..294797f2f5ab8 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -455,7 +455,7 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM "; -if ($search_bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +if ($search_bid>0) $sql.= MAIN_DB_PREFIX."bank_class as l,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_extrafields as ef on (b.rowid = ef.fk_object)"; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index df4909faad6f0..cfcb117b0a86d 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -52,7 +52,6 @@ $modetax = $conf->global->TAX_MODE; if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha'); - /** * print function * @@ -174,16 +173,16 @@ function pt ($db, $sql, $date) $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); - + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; $parameters["type"] = 'localtax'.$localTaxType; - + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -198,7 +197,7 @@ function pt ($db, $sql, $date) break; } - + print ''; print ''; if($CalcLT==0) { @@ -229,7 +228,7 @@ function pt ($db, $sql, $date) } $subtotalcoll = $subtotalcoll + $x_coll; print ""; - + } if($CalcLT==0) { @@ -239,7 +238,7 @@ function pt ($db, $sql, $date) } elseif($CalcLT==2) { $diff= $x_coll; } - + $total = $total + $diff; $subtotal = $subtotal + $diff; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index b5e6fee4f6f41..5692f3d97bb32 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -107,13 +107,13 @@ if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = $conf->global->ACCOUNTING_MODE; @@ -253,8 +253,8 @@ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f"; $sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE f.numero_compte = aa.account_number"; - //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; $sql.= " AND f.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; @@ -295,7 +295,7 @@ if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'"; - $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$charofaccountstring."'"; + $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; //$tmppredefinedgroupwhere.= " AND thirdparty_code = '".$db->escape($objp->name)."'"; // Get cpts of category/group @@ -312,7 +312,7 @@ } - if ($showaccountdetail == 'all' || $resultN > 0) + if ($showaccountdetail == 'all' || $resultN <> 0) { print ''; print ''; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 26647d5f0f0c1..e8b00fc869b0c 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -85,13 +85,14 @@ if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); + // Security check $socid = GETPOST('socid','int'); @@ -376,7 +377,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -409,7 +409,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -443,7 +442,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -474,7 +472,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -537,7 +534,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -600,7 +596,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -647,7 +642,6 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $var = false; $i = 0; if ($num) { while ($i < $num) { @@ -775,7 +769,6 @@ if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -810,32 +803,35 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) { - $subtotal_ht = 0; - $subtotal_ttc = 0; + $predefinedgroupwhere = "("; + //$predefinedgroupwhere.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'EXPENSE')"; + $predefinedgroupwhere.= " OR "; + //$predefinedgroupwhere.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'INCOME')"; + $predefinedgroupwhere.= ")"; + + $charofaccountstring = $conf->global->CHARTOFACCOUNTS; + $charofaccountstring=dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); $sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity; - //$sql.= " AND fk_statut in (1,2)"; - $sql.= " AND ("; - //$sql.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'EXPENSE')"; - $sql.= " OR "; - //$sql.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'INCOME')"; - $sql.= ")"; - //$sql.= " AND code_journal in ('VT', 'AC')"; + $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm"; //print $sql; + $subtotal_ht = 0; + $subtotal_ttc = 0; + dol_syslog("get bookkeeping record"); $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -845,9 +841,8 @@ if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->debit; - if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; - $encaiss_ttc[$obj->dm] += $obj->credit; + $encaiss_ttc[$obj->dm] += 0; $i++; } @@ -908,7 +903,6 @@ } print ''; -$var=True; // Loop on each month $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; @@ -926,21 +920,44 @@ $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage)); print '"; print '"; } @@ -951,7 +968,10 @@ // Total $nbcols=0; -print ''; +print ''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { $nbcols+=2; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index bbe05ea1111a6..0ccd7013ba412 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -160,8 +160,8 @@ function pt ($db, $sql, $date) $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 1b60a5603bbe4..92b67dbfd6fcb 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -198,8 +198,8 @@ $columns = 5; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index da77c5a4f9b4c..5bdc58cc61a0a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6551,7 +6551,7 @@ protected function isIndex($info) * * @return array */ - protected function set_save_query() + protected function setSaveQuery() { global $conf; @@ -6650,7 +6650,7 @@ protected function setVarsFromFetchObj(&$obj) * * @return string */ - protected function get_field_list() + protected function getFieldList() { $keys = array_keys($this->fields); return implode(',', $keys); @@ -6685,7 +6685,7 @@ public function createCommon(User $user, $notrigger = false) $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. @@ -6778,7 +6778,7 @@ public function fetchCommon($id, $ref = null, $morewhere = '') { if (empty($id) && empty($ref)) return false; - $sql = 'SELECT '.$this->get_field_list(); + $sql = 'SELECT '.$this->getFieldList(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; if (!empty($id)) $sql.= ' WHERE rowid = '.$id; @@ -6822,7 +6822,7 @@ public function updateCommon(User $user, $notrigger = false) $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index aaae010c2fe62..a79f01352e872 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -243,7 +243,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '' * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. - * @param int $showempty Add an empty field + * @param int $showempty 1=Add an empty field, 2=Add an empty field+'None' field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number @@ -253,7 +253,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '' */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') { - global $conf; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -318,7 +318,12 @@ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + if ($showempty == 2) + { + $options['0'] = $langs->trans("None"); + } + + $out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index ab792f07771f4..3f0530e82fbc2 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -32,7 +32,7 @@ * Prepare array with list of tabs * * @param ChargeSociales $object Object related to tabs - * @return array Array of tabs to show + * @return array Array of tabs to show */ function tax_prepare_head(ChargeSociales $object) { @@ -184,7 +184,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * Gets Tax to collect for the given year (and given quarter or month) * The function gets the Tax in split results, as the Tax declaration asks * to report the amounts for different Tax rates as different lines. - * This function also accounts recurrent invoices. * * @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2' * @param DoliDB $db Database handler object @@ -237,7 +236,11 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax1='total_localtax1'; $total_localtax2='total_localtax2'; +<<<<<<< HEAD // CAS DES BIENS/PRODUITS +======= + // CAS DES BIENS +>>>>>>> branch '7.0' of git@github.com:Dolibarr/dolibarr.git // Define sql request $sql=''; @@ -323,7 +326,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($sql == 'TODO') return -2; if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -466,13 +469,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -565,13 +568,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -633,24 +636,3 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire return $list; } -/** - * Gets VAT to collect for the given year (and given quarter or month) - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option vat on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $m Month - * @return array List of quarters with vat - */ -function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) -{ - return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m); -} - diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index e1a3b46bcf18c..57d57c06bef15 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -85,6 +85,10 @@ EmployeeFirstname=Prénom du salarié TypeWasDisabledOrRemoved=Le type de congés (id %s) a été désactivé ou supprimé LastHolidays=Les %s dernières demandes de congés AllHolidays=Toutes les demandes de congés +LEAVE_PAID=Congé payés +LEAVE_SICK=Arrêt maladie +LEAVE_OTHER=Autre congé +LEAVE_PAID_FR=congé payés ## Configuration du Module ## LastUpdateCP=Dernière mise à jour automatique de l'allocation des congés
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."
 '; - if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + if ($modecompta == 'BOOKKEEPING') + { + if (isset($decaiss[$case]) && $decaiss[$case] != 0) + { + print ''.price(price2num($decaiss[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss[$case]; + } + } + else { - print ''.price(price2num($decaiss_ttc[$case],'MT')).''; - if (! isset($totsorties[$annee])) $totsorties[$annee]=0; - $totsorties[$annee]+=$decaiss_ttc[$case]; + if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + { + print ''.price(price2num($decaiss_ttc[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss_ttc[$case]; + } } print " '; - //if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0) - if (isset($encaiss_ttc[$case])) + if ($modecompta == 'BOOKKEEPING') + { + if (isset($encaiss[$case])) + { + print ''.price(price2num($encaiss[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss[$case]; + } + } + else { - print ''.price(price2num($encaiss_ttc[$case],'MT')).''; - if (! isset($totentrees[$annee])) $totentrees[$annee]=0; - $totentrees[$annee]+=$encaiss_ttc[$case]; + if (isset($encaiss_ttc[$case])) + { + print ''.price(price2num($encaiss_ttc[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss_ttc[$case]; + } } print "
'.$langs->trans("TotalTTC").'
'; +if ($modecompta == 'BOOKKEEPING') print $langs->trans("Total"); +else print $langs->trans("TotalTTC"); +print '