FIX Accountancy - Mass cloning - Complete sql_insert (#34285)

This commit is contained in:
Alexandre SPANGARO
2025-05-26 11:09:55 +02:00
committed by GitHub
parent c08ce9eeca
commit a8137faa2b
3 changed files with 12 additions and 6 deletions

View File

@@ -57,7 +57,7 @@ $langs->loadLangs(array("accountancy", "compta"));
$socid = GETPOSTINT('socid');
$journal_code = GETPOST('code_journal', 'alpha');
$account = GETPOST("account", 'int');
$massdate = (int) GETPOSTINT('massdate');
$massdate = dol_mktime(0, 0, 0, GETPOSTINT('massdatemonth'), GETPOSTINT('massdateday'), GETPOSTINT('massdateyear'));
// action+display Parameters
$action = GETPOST('action', 'aZ09');

View File

@@ -53,7 +53,7 @@ $langs->loadLangs(array("accountancy", "compta"));
$journal_code = GETPOST('code_journal', 'alpha');
$account = GETPOST("account", 'int');
$massdate = (int) GETPOSTINT('massdate');
$massdate = dol_mktime(0, 0, 0, GETPOSTINT('massdatemonth'), GETPOSTINT('massdateday'), GETPOSTINT('massdateyear'));
$action = GETPOST('action', 'aZ09');
$socid = GETPOSTINT('socid');

View File

@@ -3605,11 +3605,17 @@ class BookKeeping extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$docRef = "Duplicata de " . $obj->doc_ref;
$docRef = $langs->trans("CloneOf", $obj->doc_ref);
$sql_insert = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, doc_date, fk_user_author, doc_ref, fk_doc, fk_docdet, debit, credit, date_creation, journal_label, sens, montant)";
$sql_insert .= " VALUES (" . ((int) $pieceNumNext) . ", '" . $this->db->escape($obj->label_operation) . "', '" . $this->db->escape($obj->numero_compte) . "', '" . $this->db->escape($obj->label_compte) . "', '" . $this->db->escape($obj->doc_type) . "', '" . $this->db->escape($code_journal) . "', '" . $this->db->idate($docdate)."'";
$sql_insert .= 'Bug here !!! code to forge sql_insert is not finished';
$sql_insert = "INSERT INTO ".$this->db->prefix()."accounting_bookkeeping";
$sql_insert .= " (piece_num, label_operation, numero_compte, label_compte, doc_type, code_journal, doc_date,";
$sql_insert .= " fk_user_author, doc_ref, fk_doc, fk_docdet, debit, credit, journal_label, sens, montant";
$sql_insert .= ")";
$sql_insert .= " VALUES (" . ((int) $pieceNumNext) . ", '" . $this->db->escape($obj->label_operation) . "', '" . $this->db->escape($obj->numero_compte) . "',";
$sql_insert .= " '" . $this->db->escape($obj->label_compte) . "', '" . $this->db->escape($obj->doc_type) . "', '" . $this->db->escape($code_journal) . "', '" . $this->db->idate($docdate)."',";
$sql_insert .= " '" . $this->db->escape($obj->fk_user_author) . "', '" . $this->db->escape($docRef) . "', " . ((int) $obj->fk_doc) . ", " . ((int) $obj->fk_docdet) . ",";
$sql_insert .= " " . (float) $obj->debit . ", " . (float) $obj->credit . ", '" . $this->db->escape($journal_label) . "', '" . $this->db->escape($obj->sens) . "', " . (float) $obj->montant;
$sql_insert .= ")";
$resqlInsert = $this->db->query($sql_insert);