diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c7d38ae3e1790390698d481bc9cf03d2acf4bfd4..14a0b4800c51769acd0cd345850b1844564ed797 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -136,7 +136,7 @@ else if ($action == "add") { $book->sens = 'C'; } - $result = $book->create_std($user); + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { @@ -180,7 +180,7 @@ else if ($action == "confirm_create") { $book->montant = 0; - $result = $book->create_std($user); + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); } else { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index c4a277ec8a14cf3e1512ab2a46c83b485ba73bb2..9bc63b87eba1258fb57a69eb0877926b88f7069e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -579,8 +579,12 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index a3dad82a035026e0cd81c30ffbd99fd04b5e9894..9ac6f2e0102ea62bd6cd5212bc0f8bf82272a629 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -133,7 +133,7 @@ class FormVentilation extends Form $select_value_out = $obj->rowid; if ($select_out == 1) $select_value_out = $obj->account_number; - // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $select_value_in) { // $out .= '<option value="' . $obj->account_number . '" selected>' . $label . '</option>'; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index ce5011043da9cd9038f0abe9bfb5148c5f4227d3..06446fdc908ccd9306c4ce48afefaca2f07bf625 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -87,6 +87,50 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('Dispatched'), null, 'mesgs'); } +} elseif ($action == 'fixaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; + $sql1 .= ' (SELECT accnt.rowid '; + $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as accnt'; + $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } +} elseif ($action == 'cleanaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 .= " SET fd.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(dol_get_first_day($year_current, 1, false)) . "'"; + $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } } /* @@ -100,7 +144,11 @@ $textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); print '<b>' . $langs->trans("DescVentilCustomer") . '</b>'; -print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>'; +print '<div class="inline-block divButAction">'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; +print '</div>'; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; @@ -345,4 +393,4 @@ print "</table>\n"; print '</td></tr></table>'; llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 555a8a3818ede7205e831c01aa9195003135b681..a2a1619cb63a9265219007535cb57e8c3c03aad1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -148,7 +148,7 @@ if ($action == 'ventil' && ! empty($btn_ventil)) { dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); if ($db->query($sql)) { - print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>'; + print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>'; } else { print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>'; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 43792ca500aeb1cb67a53f939cc3b01feeaee891..314d7abbcf3d8da88423711f5b1235f19b86e82e 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -629,5 +629,4 @@ if ($action == 'export_csv') { llxFooter(); } - $db->close(); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 082fdc25fd408d10f45da77c1beac880b142b3d1..747943575b9772c6e698edc0901eab9d3206983e 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -83,6 +83,50 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('Dispatched'), null, 'mesgs'); } +} elseif ($action == 'fixaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; + $sql1 .= ' (SELECT accnt.rowid '; + $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as accnt'; + $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } +} elseif ($action == 'cleanaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.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)) . "')"; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } } /* @@ -97,7 +141,11 @@ $textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); print '<b>' . $langs->trans("DescVentilSupplier") . '</b>'; -print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>'; +print '<div class="inline-block divButAction">'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>'; +print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>'; +print '</div>'; $y = $year_current;