diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f1bea3bd4a1..c07f15a6ef4 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -213,8 +213,8 @@ for($i = 1; $i <= 12; $i ++) { } print '' . $langs->trans("Total") . ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -240,8 +240,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print '' . length_accountg($row[0]) . ''; - print '' . $row[1] . ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print ''; for($i = 2; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; } @@ -269,8 +281,8 @@ for($i = 1; $i <= 12; $i ++) { } print '' . $langs->trans("Total") . ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -296,7 +308,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print '' . length_accountg($row[0]) . ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print ''; print '' . $row[1] . ''; for($i = 2; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; @@ -363,7 +388,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } print "\n"; - + if (! empty($conf->margin->enabled)) { print "
\n"; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index b17aeedb4bd..19a0a6b5187 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -94,7 +94,7 @@ if ($action == 'validatehistory') { } dol_syslog('htdocs/accountancy/expensereport/index.php'); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -139,7 +139,7 @@ if ($action == 'validatehistory') { $sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; $sql1.=")"; - + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); @@ -194,8 +194,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -217,9 +217,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; @@ -247,8 +259,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -270,9 +282,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; @@ -292,9 +316,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. { print '
'; print '
'; - + print_fiche_titre($langs->trans("OtherInfo"), '', ''); - + print "
\n"; print '
' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '
'; print ''; @@ -302,7 +326,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; } print ''; - + $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; @@ -314,12 +338,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy - + dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - + while ( $row = $db->fetch_row($resql)) { print ''; for($i = 1; $i <= 12; $i ++) { @@ -328,7 +352,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; print ''; } - + $db->free($resql); } else { print $db->lasterror(); // Show last sql error diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 505e2a9f534..640c4b03353 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -104,12 +104,15 @@ $idpays = $mysoc->country_id; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; -$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,"; -$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop"; +$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,"; +$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,"; +$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; @@ -147,6 +150,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + //print $sql; // Variables $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word @@ -172,13 +176,31 @@ if ($result) { { $obj = $db->fetch_object($result); - // Set accountancy code (for bank and thirdparty) + $lineisapurchase = -1; + $lineisasale = -1; + // Old method to detect if it's a sale or purchase + if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1; + if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1; + // Try a more reliable method to detect if record is a supplier payment or a customer payment + if ($lineisapurchase < 0) + { + if ($obj->typeop_payment_supplier == 'payment_supplier') $lineisapurchase = 1; + } + if ($lineisasale < 0) + { + if ($obj->typeop_payment == 'payment') $lineisasale = 1; + } + //var_dump($obj->type_payment); var_dump($obj->type_payment_supplier); + //var_dump($lineisapurchase); //var_dump($lineisasale); + + // Set accountancy code for bank $compta_bank = $obj->account_number; + // Set accountancy code for thirdparty $compta_soc = 'NotDefined'; - if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') + if ($lineisapurchase > 0) $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier); - if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') + if ($lineisasale > 0) $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); $tabcompany[$obj->rowid] = array ( @@ -187,6 +209,7 @@ if ($result) { 'code_compta' => $compta_soc, ); + // Set accountancy code for user $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $tabuser[$obj->rowid] = array ( @@ -202,6 +225,7 @@ if ($result) { $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; + $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); @@ -214,7 +238,7 @@ if ($result) { //var_dump($tabpay); // By default - $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url. + $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabtype[$obj->rowid] = 'unknown'; // get_url may return -1 which is not traversable @@ -604,6 +628,8 @@ if (! $error && $action == 'writebookkeeping') { } } + + // Export if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; @@ -737,6 +763,22 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); + + // Test that setup is complete + $sql='SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL'; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj->nb > 0) + { + print img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); + print ' : '.$langs->trans("AccountancyAreaDescBank", 9, ''.$langs->transnoentitiesnoconv("MenuBankCash").''); + } + } + else dol_print_error($db); + + // Button to write into Ledger if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' @@ -797,8 +839,10 @@ if (empty($action) || $action == 'view') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { + //var_dump($tabpay[$key]); + print ''; print ''; - print ""; + print ""; print ""; print ""; // Ledger account @@ -819,11 +863,14 @@ if (empty($action) || $action == 'view') { } else print $accounttoshow;*/ print ""; - if ($val['soclib'] == '') { - print ""; - } else { - print ""; + print ""; print ""; print ""; print ""; @@ -834,14 +881,15 @@ if (empty($action) || $action == 'view') { if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { + print ''; print ''; - print ""; + print ""; print ""; print ""; // Ledger account print "'; - print ""; + print ""; print ""; print ""; // Ledger account @@ -936,7 +989,7 @@ $db->close(); * Return source for doc_ref of a bank transaction * * @param string $val Array of val - * @param string $typerecord Type of record + * @param string $typerecord Type of record ('payment', 'payment_supplier', 'payment_expensereport', 'payment_vat', ...) * @return string|unknown */ function getSourceDocRef($val, $typerecord) diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index f862feb5ba3..3dac6a23567 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -190,8 +190,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -213,8 +213,20 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; + print ''; + print ''; for($i = 2; $i <= 12; $i ++) { print ''; } @@ -244,8 +256,8 @@ for($i = 1; $i <= 12; $i ++) { } print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } @@ -267,9 +279,21 @@ if ($resql) { while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { print ''; } print ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 016fc5e0499..a0f36c409de 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -390,13 +390,13 @@ if ($rowid > 0) } if ($status != '') { - $sql.= " AND d.statut IN (".$status.")"; // Peut valoir un nombre ou liste de nombre separes par virgules + $sql.= " AND d.statut IN (".$db->escape($status).")"; // Peut valoir un nombre ou liste de nombre separes par virgules } if ($action == 'search') { if (GETPOST('search')) { - $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search')); + $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha')); } } if (! empty($search_lastname)) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ecf95c5096d..05d9049ff03 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1540,17 +1540,30 @@ class Categorie extends CommonObject dol_mkdir($dir); } - if (file_exists($dir)) - { - $originImage = $dir . $file['name']; + if (file_exists($dir)) { + if (is_array($file['name']) && count($file['name']) > 0) { + for($i = 0; $i <= count($file['name']); $i ++) { - // Cree fichier en taille origine - dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); + $originImage = $dir . $file['name'][$i]; - if (file_exists($originImage)) - { - // Create thumbs - $this->addThumbs($originImage); + // Cree fichier en taille origine + dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); + + if (file_exists($originImage)) { + // Create thumbs + $this->addThumbs($originImage); + } + } + } else { + $originImage = $dir . $file['name']; + + // Cree fichier en taille origine + dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); + + if (file_exists($originImage)) { + // Create thumbs + $this->addThumbs($originImage); + } } } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index a0744fcfa04..ce6a9cf9896 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -640,16 +640,16 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]=$this->transformToSQL('t.firstname',$arrayquery['contact_firstname']); } if (!empty($arrayquery['contact_country']) && count($arrayquery['contact_country'])) { - $sqlwhere[]= " (t.fk_pays IN (".implode(',',$arrayquery['contact_country'])."))"; + $sqlwhere[]= " (t.fk_pays IN (".$db->escape(implode(',',$arrayquery['contact_country']))."))"; } if (!empty($arrayquery['contact_status']) && count($arrayquery['contact_status'])>0) { - $sqlwhere[]= " (t.statut IN (".implode(',',$arrayquery['contact_status'])."))"; + $sqlwhere[]= " (t.statut IN (".$db->escape(implode(',',$arrayquery['contact_status']))."))"; } if (!empty($arrayquery['contact_civility']) && count($arrayquery['contact_civility'])>0) { - $sqlwhere[]= " (t.civility IN ('".implode("','",$arrayquery['contact_civility'])."'))"; + $sqlwhere[]= " (t.civility IN ('".$db->escape(implode("','",$arrayquery['contact_civility']))."'))"; } if ($arrayquery['contact_no_email']!='') { - $sqlwhere[]= " (t.no_email='".$arrayquery['contact_no_email']."')"; + $sqlwhere[]= " (t.no_email='".$db->escape($arrayquery['contact_no_email'])."')"; } if ($arrayquery['contact_update_st_dt']!='') { $sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')"; @@ -658,7 +658,7 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= " (t.datec >= '".$this->db->idate($arrayquery['contact_create_st_dt'])."' AND t.datec <= '".$this->db->idate($arrayquery['contact_create_end_dt'])."')"; } if (!empty($arrayquery['contact_categ']) && count($arrayquery['contact_categ'])>0) { - $sqlwhere[]= " (contactcateg.fk_categorie IN (".implode(",",$arrayquery['contact_categ'])."))"; + $sqlwhere[]= " (contactcateg.fk_categorie IN (".$db->escape(implode(",",$arrayquery['contact_categ']))."))"; } //Standard Extrafield feature diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 5c74c8374a0..273862f68bf 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -92,7 +92,7 @@ dol_mkdir($dir); $stats = new PropaleStats($db, $socid, ($userid>0?$userid:0), $mode); -if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$object_status.')'; +if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->escape($object_status).')'; // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); @@ -299,7 +299,7 @@ foreach ($data as $val) while (! empty($year) && $oldyear > $year+1) { // If we have empty year $oldyear--; - + print ''; print ''; print ''; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index ed9f8906804..6a8b57e3707 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -88,11 +88,11 @@ dol_mkdir($dir); $stats = new CommandeStats($db, $socid, $mode, ($userid>0?$userid:0)); if ($mode == 'customer') { - if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND c.fk_statut IN ('.$object_status.')'; + if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND c.fk_statut IN ('.$db->escape($object_status).')'; } if ($mode == 'supplier') { - if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND c.fk_statut IN ('.$object_status.')'; + if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND c.fk_statut IN ('.$db->escape($object_status).')'; } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 55ff4dad6e3..bf54e4f58ab 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -84,11 +84,11 @@ dol_mkdir($dir); $stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0)); if ($mode == 'customer') { - if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$object_status.')'; + if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; } if ($mode == 'supplier') { - if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$object_status.')'; + if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; } // Build graphic number of object @@ -299,7 +299,7 @@ foreach ($data as $val) while ($year && $oldyear > $year+1) { // If we have empty year $oldyear--; - + print ''; print ''; print ''; @@ -310,7 +310,7 @@ foreach ($data as $val) print ''; print ''; } - + print ''; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b7a2b46dfc0..c8ea494ad3a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1918,7 +1918,7 @@ class Form $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if (count($warehouseStatusArray)) { - $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.implode(',',$warehouseStatusArray).'))'; + $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$db->escape(implode(',',$warehouseStatusArray)).'))'; } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index e0283ac9a9f..1f2f499fbac 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -49,7 +49,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface public function isActive() { global $conf; - + // This function does not exists on some ISP (Ex: Free in France) if (!function_exists('openlog')) return 0; @@ -81,15 +81,15 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface */ public function checkConfiguration() { - global $langs; + global $conf, $langs; $errors = array(); - $facility = SYSLOG_FACILITY; + $facility = constant($conf->global->SYSLOG_FACILITY); if ($facility) { // Only LOG_USER supported on Windows - if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; + if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER'); dol_syslog("admin/syslog: facility ".$facility); } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 5521b233a28..9602b69a615 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -92,11 +92,11 @@ $sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p $sql.= " ON p.rowid = d.fk_projet WHERE 1 = 1"; if ($statut != '' && $statut != '-1') { - $sql .= " AND d.fk_statut IN (".$statut.")"; + $sql .= " AND d.fk_statut IN (".$db->escape($statut).")"; } if (trim($search_ref) != '') { - $sql.= natural_search('d.ref',$search_ref); + $sql.= natural_search('d.ref', $search_ref); } if (trim($search_all) != '') { diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index e158e4728a8..d0e3a1164bc 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -74,7 +74,7 @@ print load_fiche_titre($title, $mesg); dol_mkdir($dir); $stats = new ExpenseReportStats($db, $socid, $userid); -if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$object_status.')'; +if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$db->escape($object_status).')'; // Build graphic number of object // $data = array(array('Lib',val1,val2,val3),...) @@ -262,7 +262,7 @@ foreach ($data as $val) while ($year && $oldyear > $year+1) { // If we have empty year $oldyear--; - + print ''; print ''; print ''; @@ -271,7 +271,7 @@ foreach ($data as $val) print ''; } - + print ''; print ''; print ''; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 4daa0b7e00d..1c0ba5764ed 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -75,7 +75,7 @@ print load_fiche_titre($title,'','title_commercial.png'); dol_mkdir($dir); $stats = new FichinterStats($db, $socid, $mode, ($userid>0?$userid:0)); -if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$object_status.')'; +if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_statut IN ('.$db->escape($object_status).')'; // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); @@ -291,7 +291,7 @@ foreach ($data as $val) while (! empty($year) && $oldyear > $year+1) { // If we have empty year $oldyear--; - + print ''; print ''; @@ -304,7 +304,7 @@ foreach ($data as $val) print ''; } - + print ''; print ''; print ''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ee9a6b3e490..ac67d256824 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -535,9 +535,9 @@ if ($search_request_author) $sql.=natural_search(array('u.lastname','u.firstname if ($billed != '' && $billed >= 0) $sql .= " AND cf.billed = ".$billed; //Required triple check because statut=0 means draft filter -if (GETPOST('statut', 'alpha') !== '') +if (GETPOST('statut', 'intcomma') !== '') { - $sql .= " AND cf.fk_statut IN (".$db->escape(GETPOST('statut', 'alpha')).")"; + $sql .= " AND cf.fk_statut IN (".$db->escape($db->escape(GETPOST('statut', 'intcomma'))).")"; } if ($search_status != '' && $search_status >= 0) { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index e200f0ca7c0..0ef6afd193a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -54,7 +54,7 @@ AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for speci AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s. AccountancyAreaDescMisc=STEP %s: Define mandatory default account and default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s. -AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. +AccountancyAreaDescBank=STEP %s: Define accounting accounts and journal code for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s. @@ -63,6 +63,7 @@ AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and genera AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. +TheJournalCodeIsNotDefinedOnSomeBankAccount=A mandatory step in setup was not complete (accountancy code journal not defined for all bank accounts) MenuAccountancy=Accountancy Selectchartofaccounts=Select active chart of accounts ChangeAndLoad=Change and load @@ -273,5 +274,6 @@ BookeppingLineAlreayExists=Lines already existing into bookeeping NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind +UseMenuToSetBindindManualy=Autodection not possible, use menu %s to make the binding manually WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version. diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 1dbfbc7662f..c526e7ae52b 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -57,7 +57,7 @@ class FormProduct * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. * @param string $status warehouse status filter, following comma separated filter options can be used * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, + * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true * @param array $exclude warehouses ids to exclude @@ -68,28 +68,28 @@ class FormProduct global $conf, $langs; if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product - + if (is_array($exclude)) $excludeGroups = implode("','",$exclude); $warehouseStatus = array(); - if (preg_match('/warehouseclosed/', $status)) + if (preg_match('/warehouseclosed/', $status)) { $warehouseStatus[] = Entrepot::STATUS_CLOSED; } - if (preg_match('/warehouseopen/', $status)) + if (preg_match('/warehouseopen/', $status)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_ALL; } - if (preg_match('/warehouseinternal/', $status)) + if (preg_match('/warehouseinternal/', $status)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL; } - + $sql = "SELECT e.rowid, e.label, e.description, e.fk_parent"; - if (!empty($fk_product)) + if (!empty($fk_product)) { - if (!empty($batch)) + if (!empty($batch)) { $sql.= ", pb.qty as stock"; } @@ -107,7 +107,7 @@ class FormProduct if (!empty($fk_product)) { $sql.= " AND ps.fk_product = '".$fk_product."'"; - if (!empty($batch)) + if (!empty($batch)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; } @@ -115,15 +115,15 @@ class FormProduct $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql.= " AND e.statut IN (".implode(',',$warehouseStatus).")"; + $sql.= " AND e.statut IN (".$db->escape(implode(',',$warehouseStatus)).")"; } else { $sql.= " AND e.statut = 1"; } - - if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.implode(',', $exclude).')'; - + + if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$db->escape(implode(',', $exclude)).')'; + if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description, e.fk_parent"; $sql.= " ORDER BY e.label"; @@ -144,7 +144,7 @@ class FormProduct $this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock; $i++; } - + // Full label init foreach($this->cache_warehouses as $obj_rowid=>$tab) { $this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab); @@ -158,18 +158,18 @@ class FormProduct return -1; } } - + /** * Return full path to current warehouse in $tab (recursive function) - * + * * @param array $tab warehouse data in $this->cache_warehouses line * @param String $final_label full label with all parents, separated by ' >> ' (completed on each call) * @return String full label with all parents, separated by ' >> ' */ private function get_parent_path($tab, $final_label='') { - + if(empty($final_label)) $final_label = $tab['label']; - + if(empty($tab['parent_id'])) return $final_label; else { if(!empty($this->cache_warehouses[$tab['parent_id']])) { @@ -177,9 +177,9 @@ class FormProduct return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); } } - + return $final_label; - + } /** @@ -189,7 +189,7 @@ class FormProduct * @param string $htmlname Name of html select html * @param string $filterstatus warehouse status filter, following comma separated filter options can be used * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, + * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param int $empty 1=Can be empty, 0 if not * @param int $disabled 1=Select is disabled @@ -208,7 +208,7 @@ class FormProduct global $conf,$langs,$user; dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss",LOG_DEBUG); - + $out=''; if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = ''; $this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude); @@ -221,7 +221,7 @@ class FormProduct $out.= $comboenhancement; $nodatarole=($comboenhancement?' data-role="none"':''); } - + $out.='\n"; print ''; -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer -if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); -if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -945,12 +945,12 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 6a8a0884ce2..e6e205def8a 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -284,7 +284,7 @@ if ($search_montant_vat != '') $sql.= natural_search("sp.tva", $search_montant_v if ($search_montant_ttc != '') $sql.= natural_search("sp.total", $search_montant_ttc, 1); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($socid) $sql.= ' AND s.rowid = '.$socid; -if ($search_status >= 0 && $search_status != '') $sql.= ' AND sp.fk_statut IN ('.$search_status.')'; +if ($search_status >= 0 && $search_status != '') $sql.= ' AND sp.fk_statut IN ('.$db->escape($search_status).')'; if ($month > 0) { if ($year > 0 && empty($day))
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[13]) . '
" . $date . "" . $ref . "" . $langs->trans("Bank") . " - " . $reflabel . "" . $langs->trans("Bank") . " - " . $val['soclib'] . ""; + //var_dump($tabpay[$key]); + print $langs->trans("Bank"); + print ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + print " - " . $val['soclib']; } + print "" . $val["type_payment"] . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $ref . ""; $account_ledger = $k; - + // Try to force general ledger account depending on type if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; @@ -878,7 +926,11 @@ if (empty($action) || $action == 'view') { { if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + /*var_dump($tabpay[$key]); + var_dump($tabtype[$key]); + var_dump($tabbq[$key]);*/ + //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown").''; } else print $accounttoshowsubledger; } @@ -893,8 +945,9 @@ if (empty($action) || $action == 'view') { } } else { foreach ( $tabbq[$key] as $k => $mt ) { + print ''; print '
" . $date . "" . $ref . "' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '
'; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); + } + else print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); + } + else print $row[1]; + print '' . price($row[$i]) . '' . price($row[13]) . '
0?'&userid='.$userid:'').'">'.$oldyear.'0
0?'&userid='.$userid:'').'">'.$oldyear.'0
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].'
'.$oldyear.'0
'.$year.''.$val['nb'].'
0?'&userid='.$userid:'').'">'.$oldyear.'
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].'