diff --git a/ChangeLog b/ChangeLog index 7daade7ae2a..951c4297f0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ Following changes may create regressions for some external modules, but were nec * API /setup/shipment_methods has been replaced with API /setup/shipping_methods * Field "tva" renamed into "total_tva" in llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency * Field "total" renamed into "total_ttc" in llx_propal, llx_supplier_proposal for better field name consistency +* If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT) +* If your database is MySql or MariaDB, you need at least version 5.1 ***** ChangeLog for 13.0.1 compared to 13.0.0 ***** diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php deleted file mode 100644 index 20fe0c1aef4..00000000000 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ /dev/null @@ -1,135 +0,0 @@ - - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * \file htdocs/accountancy/bookkeeping/balancebymonth.php - * \ingroup Accountancy (Double entries) - * \brief Balance by month - */ -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("bills", "compta", "accountancy", "other")); - -// Filter -$year = GETPOST("year", 'int'); -if ($year == 0) { - $year_current = strftime("%Y", time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} - - -/* - * View - */ - -llxHeader('', $langs->trans("Bookkeeping")); - -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; - -print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear); - -$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f"; -$sql .= " WHERE fd.fk_code_ventilation = 0"; -$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; - -dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql); -$result = $db->query($sql); -if ($result) { - $row = $db->fetch_row($result); - $nbfac = $row[0]; - - $db->free($result); -} - -$y = $year_current; - -print ''; -print ''; -print ''; -for ($i = 1; $i <= 12; $i++) { - print ''; -} -print ''; -print ''; - -$sql = "SELECT bk.numero_compte AS 'compte',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; -$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; -$sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; -$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; -$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; -$sql .= " GROUP BY bk.numero_compte"; - -$resql = $db->query($sql); -if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($i < $num) { - $row = $db->fetch_row($resql); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $i++; - } - $db->free($resql); -} else { - print $db->lasterror(); -} -print "
'.$langs->trans("Label").''.$langs->trans("MonthShort".sprintf("%02s", $i)).''.$langs->trans("Total").'
'.length_accountg($row[0]).''.price($row[1]).''.price($row[2]).''.price($row[3]).''.price($row[4]).''.price($row[5]).''.price($row[6]).''.price($row[7]).''.price($row[8]).''.price($row[9]).''.price($row[10]).''.price($row[11]).''.price($row[12]).''.price($row[13]).'
\n"; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index bc103edbf1b..a2192d5ea60 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -145,7 +145,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index 3da345add6a..f8167846aff 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -144,7 +144,7 @@ print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; -$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; +$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated "; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )"; if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 35e32bf2004..4467844b04e 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -359,7 +359,7 @@ class AccountancyExport print length_accountg($line->numero_compte).$separator; print length_accounta($line->subledger_account).$separator; print $line->sens.$separator; - print price2fec(abs($line->montant)).$separator; + print price2fec(abs($line->debit - $line->credit)).$separator; print dol_string_unaccent($line->label_operation).$separator; print dol_string_unaccent($line->doc_ref); print $end_line; @@ -387,11 +387,11 @@ class AccountancyExport print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { - print price($line->montant).$separator; + print price($line->debit).$separator; print ''.$separator; } elseif ($line->sens == 'C') { print ''.$separator; - print price($line->montant).$separator; + print price($line->credit).$separator; } print $line->doc_ref.$separator; print $line->label_operation.$separator; @@ -493,7 +493,7 @@ class AccountancyExport $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25); - $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34); @@ -541,20 +541,23 @@ class AccountancyExport $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); // Credit invoice - invert sens - if ($data->montant < 0) { - if ($data->sens == 'C') { - $Tab['sens'] = 'D'; - } else { - $Tab['sens'] = 'C'; - } - $Tab['signe_montant'] = '-'; - } else { - $Tab['sens'] = $data->sens; // C or D - $Tab['signe_montant'] = '+'; - } + /* + if ($data->montant < 0) { + if ($data->sens == 'C') { + $Tab['sens'] = 'D'; + } else { + $Tab['sens'] = 'C'; + } + $Tab['signe_montant'] = '-'; + } else { + $Tab['sens'] = $data->sens; // C or D + $Tab['signe_montant'] = '+'; + }*/ + $Tab['sens'] = $data->sens; // C or D + $Tab['signe_montant'] = '+'; // The amount must be in centimes without decimal points. - $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); // Force date format : %d%m%y @@ -640,13 +643,13 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); - $Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30); @@ -707,7 +710,7 @@ class AccountancyExport //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; - print price2num(abs($line->montant)).$separator; + print price2num(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $date.$separator; //print 'EUR'; @@ -747,7 +750,7 @@ class AccountancyExport print self::toAnsi($line->doc_ref).$separator; print price($line->debit).$separator; print price($line->credit).$separator; - print price($line->montant).$separator; + print price(abs($line->debit - $line->credit)).$separator; print $line->sens.$separator; print $line->lettering_code.$separator; print $line->code_journal; @@ -810,7 +813,7 @@ class AccountancyExport $tab[] = length_accounta($line->subledger_account); $tab[] = price2num($line->debit); $tab[] = price2num($line->credit); - $tab[] = price2num($line->montant); + $tab[] = price2num($line->debit - $line->credit); $tab[] = $line->code_journal; print implode($separator, $tab).$this->end_line; @@ -853,8 +856,8 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); - } else { + //unset($array[$line]); + } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); @@ -959,7 +962,7 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d'); @@ -1110,11 +1113,7 @@ class AccountancyExport // Code print '""'.$this->separator; // Netto - if ($line->montant >= 0) { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } + print abs($line->debit - $line->credit).$this->separator; // Steuer print "0.00".$this->separator; // FW-Betrag @@ -1190,13 +1189,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1220,7 +1219,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1451,13 +1450,13 @@ class AccountancyExport print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) > 0) { $nature_piece = 'AF'; } else { $nature_piece = 'FF'; } } elseif ($line->doc_type == 'customer_invoice') { - if ($line->montant < 0) { + if (($line->debit - $line->credit) < 0) { $nature_piece = 'AC'; } else { $nature_piece = 'FC'; @@ -1481,7 +1480,7 @@ class AccountancyExport print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2).$separator; + print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator; // CODC print $line->sens.$separator; // CPTG @@ -1602,7 +1601,7 @@ class AccountancyExport print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->doc_ref, 20).$separator; //Piece print self::trunc($line->label_operation, 60).$separator; //Operation label - print price(abs($line->montant)).$separator; //Amount + print price(abs($line->debit - $line->credit)).$separator; //Amount print $line->sens.$separator; //Direction print $separator; //Analytic print $separator; //Analytic @@ -1631,7 +1630,7 @@ class AccountancyExport $supplier_invoices_infos = array(); foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); @@ -1699,8 +1698,8 @@ class AccountancyExport print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; //Devise print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; + //Amount + print price2num(abs($line->debit - $line->credit)) . $this->separator; //Sens print $line->sens . $this->separator; //Code lettrage @@ -1726,14 +1725,14 @@ class AccountancyExport foreach ($objectLines as $line) { if ($line->debit == 0 && $line->credit == 0) { - unset($array[$line]); + //unset($array[$line]); } else { $date = dol_print_date($line->doc_date, '%d%m%Y'); print $line->id . $this->separator; print $date . $this->separator; print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value print length_accountg($line->subledger_account) . $this->separator; } else { print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; @@ -1742,7 +1741,7 @@ class AccountancyExport //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator; - print price2num($line->montant) . $this->separator; + print price2num(abs($line->debit - $line->credit)) . $this->separator; print $line->sens . $this->separator; print $date . $this->separator; print $this->separator; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8ef8979fad4..27a84270e95 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -135,6 +135,7 @@ class BookKeeping extends CommonObject /** * @var float FEC:Amount (Not necessary) + * @deprecated No more used */ public $amount; @@ -239,6 +240,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = (float) $this->montant; } + if (isset($this->amount)) { + $this->amount = (float) $this->amount; + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -563,6 +567,9 @@ class BookKeeping extends CommonObject if (isset($this->montant)) { $this->montant = trim($this->montant); } + if (isset($this->amount)) { + $this->amount = trim($this->amount); + } if (isset($this->sens)) { $this->sens = trim($this->sens); } @@ -708,7 +715,7 @@ class BookKeeping extends CommonObject $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; @@ -747,7 +754,8 @@ class BookKeeping extends CommonObject $this->label_operation = $obj->label_operation; $this->debit = $obj->debit; $this->credit = $obj->credit; - $this->montant = $obj->montant; + $this->montant = $obj->amount; + $this->amount = $obj->amount; $this->sens = $obj->sens; $this->fk_user_author = $obj->fk_user_author; $this->import_key = $obj->import_key; @@ -1207,8 +1215,8 @@ class BookKeeping extends CommonObject if (isset($this->credit)) { $this->credit = trim($this->credit); } - if (isset($this->montant)) { - $this->montant = trim($this->montant); + if (isset($this->amount)) { + $this->amount = trim($this->amount); } if (isset($this->sens)) { $this->sens = trim($this->sens); @@ -1655,7 +1663,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".$piecenum; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -1681,7 +1689,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; @@ -1714,7 +1723,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE entity IN (".getEntity('accountancy').")"; @@ -1744,7 +1753,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 32f3dfef3d5..5b2f807fcd7 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -63,7 +63,9 @@ if (GETPOST('addbox')) { * View */ -llxHeader('', $langs->trans("AccountancyArea")); +$help_url = ''; + +llxHeader('', $langs->trans("AccountancyArea"), $help_url); if ($conf->accounting->enabled) { $step = 0; @@ -91,7 +93,7 @@ if ($conf->accounting->enabled) { } - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); + print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); print '
'; // hideobject is to start hidden print "
\n"; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 6739d277192..493cfb1a109 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -180,9 +180,12 @@ if ($object->id > 0) { // Affichage fiche action en mode visu print ''; - // Type + // Type of event if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; + print ''; } // Full day event diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fcd6471604a..07ab4f797de 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -340,7 +340,7 @@ if ($object->id > 0) { print ''; // default terms of the settlement @@ -533,7 +533,7 @@ if ($object->id > 0) { print ''; } // Warehouse - if (!empty($conf->stock->enabled)) { + if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2834edb3427..1790150206b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2047,7 +2047,7 @@ if ($action == 'create') { print ''; } print '
'.$langs->trans("Type").''.$object->type.'
'.$langs->trans("Type").''; + print $object->getTypePicto(); + print $langs->trans("Action".$object->type_code); + print '
'; print $langs->trans('CustomerCode').''; - print $object->code_client; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -388,7 +388,7 @@ if ($object->id > 0) { // TVA Intra print '
'.$langs->trans('VATIntra').''; - print $object->tva_intra; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); print '
id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { print '
'; print ''; @@ -2074,7 +2074,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { print ''; print ''; @@ -2104,7 +2104,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { @@ -2117,7 +2117,7 @@ if ($action == 'create') { $langs->load('deliveries'); print ''; print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker'); - print ''; + print ''; print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker'); print ''; print ''; @@ -2134,7 +2134,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -2154,7 +2154,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editshippingmethod' && $usercancreate) { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { @@ -2172,7 +2172,7 @@ if ($action == 'create') { print ''; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); - print ''; + print ''; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); } else { @@ -2191,7 +2191,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -2202,7 +2202,7 @@ if ($action == 'create') { // Payment mode print ''; - print ''; + print ''; print ''; @@ -2210,7 +2210,7 @@ if ($action == 'create') { print ''; } print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'
'; - print ''; + print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { @@ -2230,7 +2230,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -2250,7 +2250,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; } print ''; - print ''; + print ''; if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -2272,7 +2272,7 @@ if ($action == 'create') { // Outstanding Bill print ''; print $langs->trans('OutstandingBill'); - print ''; + print ''; $arrayoutstandingbills = $soc->getOutstandingBills(); print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); @@ -2290,7 +2290,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2305,13 +2305,13 @@ if ($action == 'create') { $totalVolume = $tmparray['volume']; if ($totalWeight) { print ''.$langs->trans("CalculatedWeight").''; - print ''; + print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; } if ($totalVolume) { print ''.$langs->trans("CalculatedVolume").''; - print ''; + print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -2329,7 +2329,7 @@ if ($action == 'create') { } print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 889eb036ab4..9453764f7eb 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2067,7 +2067,7 @@ if ($action == 'create' && $usercancreate) { // Outstanding Bill print ''; print $langs->trans('OutstandingBill'); - print ''; + print ''; $arrayoutstandingbills = $soc->getOutstandingBills(); print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); @@ -2088,7 +2088,7 @@ if ($action == 'create' && $usercancreate) { $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; $addcreditnote = ''.$langs->trans("AddCreditNote").''; - print ''.$langs->trans('Discounts').''; + print ''.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2106,7 +2106,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Date", 'date', '', $object, $editenable); - print ''; + print ''; if ($action == 'editdate') { print ''; print ''; @@ -2127,7 +2127,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); - print ''; + print ''; if ($action == 'editdate_livraison') { print ''; print ''; @@ -2149,7 +2149,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); - print ''; + print ''; if ($action == 'editshippingmethod') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { @@ -2167,7 +2167,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); - print ''; + print ''; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); } else { @@ -2181,7 +2181,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); - print ''; + print ''; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { @@ -2195,7 +2195,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); - print ''; + print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { @@ -2210,7 +2210,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -2224,7 +2224,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT; print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); - print ''; + print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -2246,7 +2246,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); - print ''; + print ''; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -2258,7 +2258,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); - print ''; + print ''; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -2285,13 +2285,13 @@ if ($action == 'create' && $usercancreate) { $totalVolume = $tmparray['volume']; if ($totalWeight) { print ''.$langs->trans("CalculatedWeight").''; - print ''; + print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; } if ($totalVolume) { print ''.$langs->trans("CalculatedVolume").''; - print ''; + print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -2304,7 +2304,7 @@ if ($action == 'create' && $usercancreate) { $editenable = $usercancreate; print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { @@ -2318,7 +2318,7 @@ if ($action == 'create' && $usercancreate) { print ''; $editenable = $usercancreate; print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2343,17 +2343,17 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; - print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount VAT print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; - print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount TTC print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; - print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; } @@ -2363,23 +2363,23 @@ if ($action == 'create' && $usercancreate) { $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); } print ''.$langs->trans('AmountHT').''; - print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.''; + print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.''; // Total VAT - print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; - print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; - print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; } // Total TTC - print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; // Statut //print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 5a36e88fa0e..dda8f13437d 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -43,7 +43,10 @@ $result = restrictedArea($user, 'banque'); $companystatic = new Societe($db); -llxHeader(); +$title = $langs->trans('ListTransactionsByCategory'); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; + +llxHeader('', $title, $help_url); // List movements bu category for bank transactions print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account'); diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 5d8f15d9210..48976f8ba25 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -79,7 +79,10 @@ if ($categid) { * View */ -llxHeader(); +$title = $langs->trans('RubriquesTransactions'); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; + +llxHeader('', $title, $help_url); print load_fiche_titre($langs->trans("RubriquesTransactions"), '', 'object_category'); diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 985a09fb841..1d0613ead0a 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -158,7 +158,10 @@ if ($action == 'add') { * View */ -llxHeader(); +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; +$title = $langs->trans('MenuBankInternalTransfer'); + +llxHeader('', $title, $help_url); print ' '; - print ' - '.$langs->trans("ShowHideDetails").''; + }); + '; + print ' - '.$langs->trans("ShowHideDetails").''; //} + print ''."\n"; } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b57117ffb79..6ec53bd5f48 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -252,7 +252,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l if ($sDay > 1) { $dayTranslate = $langs->trans("Days"); } - $sTime .= $sDay.' '.$dayTranslate.' '; + $sTime .= $sDay.' '.strtolower(dol_substr($dayTranslate, 0, 1)).'. '; } if ($format == 'all') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e4f04bde0a2..673ad8206e7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3415,12 +3415,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', - 'cash-register', 'category', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes', + 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', - 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', - 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next', + 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', + 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', @@ -3436,16 +3436,17 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', 'off', 'on', 'order', - 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', - 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', - 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', + 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', + 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', + 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', 'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'shipment', 'supplier_invoice', 'technic', 'ticket', 'error', 'warning', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', - 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'user-cog', - 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', + 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', + 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', + 'user-cog', 'eventorganization', 'object_eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); @@ -3453,18 +3454,18 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; $fa = 'fas'; - if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { + if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } - if (in_array($pictowithouttext, array('black-tie', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { + if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { $fa = 'fab'; } $arrayconvpictotofa = array( - 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', + 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'shapes', - 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', + 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', @@ -3480,13 +3481,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', - 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', + 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'resource'=>'laptop-house', - 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', - 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', + 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', + 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', 'uparrow'=>'mail-forward', 'vcard'=>'address-card', 'jabber'=>'comment-o', @@ -3524,7 +3525,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('holiday', 'dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) { $morecss = 'em092'; } - if (in_array($pictowithouttext, array('holiday'))) { + if (in_array($pictowithouttext, array('holiday', 'project'))) { $morecss = 'em088'; } if (in_array($pictowithouttext, array('intervention', 'payment', 'loan', 'stock', 'technic'))) { @@ -3555,7 +3556,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'user'=>'infobox-adherent', 'users'=>'infobox-adherent', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'holiday'=>'infobox-holiday', 'invoice'=>'infobox-commande', 'loan'=>'infobox-bank_account', - 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', + 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', 'salary'=>'infobox-bank_account', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', @@ -3572,12 +3573,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $arrayconvpictotocolor = array( 'address'=>'#6c6aa8', 'building'=>'#6c6aa8', 'bom'=>'#a69944', 'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'dynamicprice'=>'#a69944', - 'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', + 'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555', 'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', 'lot'=>'#a69944', 'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944', 'other'=>'#ddd', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba', - 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa', + 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa', 'website'=>'#304' ); if (isset($arrayconvpictotocolor[$pictowithouttext])) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 1222fa120fe..49ed4c536c0 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2413,18 +2413,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { - print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); } - print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("OpportunityAmount", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); //print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); if (!in_array('plannedworkload', $hiddenfields)) { - print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right '); } if (!in_array('declaredprogress', $hiddenfields)) { - print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared")); } } if (!in_array('projectstatus', $hiddenfields)) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 42304cc7be2..749765886b4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1185,7 +1185,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); // Configuration - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1, '', '', '', img_picto('', 'setup', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); @@ -1220,7 +1220,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Transfer in accounting - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1, '', '', '', img_picto('', 'long-arrow-alt-right', 'class="paddingright pictofixedwidth"')); // Binding // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); @@ -1318,7 +1318,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Accounting - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1); + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"')); // Balance $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire); @@ -1447,7 +1447,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Assets if (!empty($conf->asset->enabled)) { - $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); + $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); $newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); @@ -1468,7 +1468,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Bank-Cash account if (!empty($conf->banque->enabled)) { - $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank'); + $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank', 0, '', '', '', img_picto('', 'bank_account', 'class="paddingright pictofixedwidth"')); $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer); $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->lire, '', $mainmenu, 'bank'); @@ -1486,7 +1486,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Direct debit order if (!empty($conf->prelevement->enabled)) { - $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); + $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer); @@ -1500,7 +1500,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Bank transfer order if (!empty($conf->paymentbybanktransfer->enabled)) { - $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer'); + $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") { $newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->rights->paymentbybanktransfer->create); @@ -1514,7 +1514,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Management of checks if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) { - $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks'); + $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); if (preg_match('/checks/', $leftmenu)) { $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque); $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque); @@ -1524,7 +1524,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Cash Control if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) { $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run); - $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol'); + $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"')); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence); } @@ -1724,12 +1724,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Project affected to user - $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'task', 'class="pictofixedwidth"')); + $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'projecttask', 'class="pictofixedwidth"')); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); - $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire); + $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', 'project', 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"')); } } } @@ -1770,7 +1770,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Trips and expenses (old module) if (!empty($conf->deplacement->enabled)) { $langs->load("trips"); - $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses'); + $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"')); $newmenu->add("/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer); $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire); $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire); @@ -1779,7 +1779,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Expense report if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); - $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport'); + $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"')); $newmenu->add("/expensereport/card.php?action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer); $newmenu->add("/expensereport/list.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire); if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") { @@ -1799,7 +1799,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $search_project_user = GETPOST('search_project_user', 'int'); - $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire); + $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"')); } } } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index ffd18c77cc6..f8f196a9fa3 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1433,7 +1433,8 @@ class pdf_einstein extends ModelePDFCommandes $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 32a5fa18c6f..b64a0066390 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1618,7 +1618,8 @@ class pdf_eratosthene extends ModelePDFCommandes $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 2747ee4e246..67e61cb7815 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1053,10 +1053,9 @@ class pdf_crabe extends ModelePDFFactures && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($conf->global->FACTURE_RIB_NUMBER)) { $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); - } - // Avoid having any valid PDF with setup that is not complete - elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) + } elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) { + // Avoid having any valid PDF with setup that is not complete $outputlangs->load("errors"); $pdf->SetXY($this->marge_gauche, $posy); @@ -1850,7 +1849,8 @@ class pdf_crabe extends ModelePDFFactures $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 49bc90f1d69..b1072a50008 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1142,10 +1142,9 @@ class pdf_sponge extends ModelePDFFactures && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($conf->global->FACTURE_RIB_NUMBER)) { $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"); - } - // Avoid having any valid PDF with setup that is not complete - elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) + } elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)) || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) { + // Avoid having any valid PDF with setup that is not complete $outputlangs->load("errors"); $pdf->SetXY($this->marge_gauche, $posy); @@ -2116,7 +2115,8 @@ class pdf_sponge extends ModelePDFFactures $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 4ba6c61c5e3..f048f070366 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -292,7 +292,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', 'b.debit'=>"Debit", - 'b.credit'=>"Credit" + 'b.credit'=>"Credit", + 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); $this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); @@ -309,7 +310,8 @@ class modAccounting extends DolibarrModules 'b.subledger_label'=>'', 'b.label_operation'=>"Sale of ABC", 'b.debit'=>"0", - 'b.credit'=>"100" + 'b.credit'=>"100", + 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); // Chart of accounts diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index a5ab8491643..b4fbb1f2e97 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -216,6 +216,7 @@ class modTakePos extends DolibarrModules 'titre'=>'PointOfSaleShort', 'mainmenu'=>'takepos', 'leftmenu'=>'', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'url'=>'/takepos/index.php', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 227b192a85d..1f36c874c2b 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1602,7 +1602,8 @@ class pdf_azur extends ModelePDFPropales $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = 100; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 368b5520421..6a550018f7a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1718,7 +1718,8 @@ class pdf_cyan extends ModelePDFPropales $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); + $mode = 'target'; + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object); // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 526d640b62a..407859037d7 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -44,7 +44,7 @@ foreach ($object->fields as $key => $val) { continue; // We don't want this field } - print ''; + print ''; print ''; if (!empty($val['picto'])) { print img_picto('', $val['picto']); } diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 8ea1befa009..a2c6868472f 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -46,7 +46,7 @@ foreach ($object->fields as $key => $val) { continue; // We don't want this field } - print ''; if (!empty($val['picto'])) { print img_picto('', $val['picto']); } diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 8fbd5aa2fb3..0e661c6e078 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -57,7 +57,7 @@ foreach ($object->fields as $key => $val) { $value = $object->$key; - print ''; + print ''; // Convert date into timestamp format if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) { diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index f325fc286a5..327e9a030e0 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -383,602 +383,611 @@ $sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $arrayofselected = is_array($toselect) ? $toselect : array(); +$num = $db->num_rows($resql); - $expedition = new Expedition($db); +$arrayofselected = is_array($toselect) ? $toselect : array(); - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($sall) { - $param .= "&sall=".urlencode($sall); - } - if ($search_ref_exp) { - $param .= "&search_ref_exp=".urlencode($search_ref_exp); - } - if ($search_ref_liv) { - $param .= "&search_ref_liv=".urlencode($search_ref_liv); - } - if ($search_ref_customer) { - $param .= "&search_ref_customer=".urlencode($search_ref_customer); - } - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_company) { - $param .= "&search_company=".urlencode($search_company); - } - if ($search_tracking) { - $param .= "&search_tracking=".urlencode($search_tracking); - } - if ($search_town) { - $param .= '&search_town='.urlencode($search_town); - } - if ($search_zip) { - $param .= '&search_zip='.urlencode($search_zip); - } - if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); - } +$expedition = new Expedition($db); - if ($search_datedelivery_start) { - $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); - } - if ($search_datedelivery_end) { - $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); - } - if ($search_datereceipt_start) { - $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start); - } - if ($search_datereceipt_end) { - $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end); - } +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall) { + $param .= "&sall=".urlencode($sall); +} +if ($search_ref_exp) { + $param .= "&search_ref_exp=".urlencode($search_ref_exp); +} +if ($search_ref_liv) { + $param .= "&search_ref_liv=".urlencode($search_ref_liv); +} +if ($search_ref_customer) { + $param .= "&search_ref_customer=".urlencode($search_ref_customer); +} +if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); +} +if ($search_company) { + $param .= "&search_company=".urlencode($search_company); +} +if ($search_tracking) { + $param .= "&search_tracking=".urlencode($search_tracking); +} +if ($search_town) { + $param .= '&search_town='.urlencode($search_town); +} +if ($search_zip) { + $param .= '&search_zip='.urlencode($search_zip); +} +if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); +} - if ($search_product_category != '') { - $param .= '&search_product_category='.urlencode($search_product_category); - } - if ($search_categ_cus > 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +if ($search_datedelivery_start) { + $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start); +} +if ($search_datedelivery_end) { + $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end); +} +if ($search_datereceipt_start) { + $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start); +} +if ($search_datereceipt_end) { + $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end); +} - $arrayofmassactions = array( - 'builddoc' => $langs->trans("PDFMerge"), - //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged - 'presend' => $langs->trans("SendByMail"), - ); - if (in_array($massaction, array('presend'))) { - $arrayofmassactions = array(); +if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); +} +if ($search_categ_cus > 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); +} +if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +$arrayofmassactions = array( + 'builddoc' => $langs->trans("PDFMerge"), + //'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged + 'presend' => $langs->trans("SendByMail"), +); +if (in_array($massaction, array('presend'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +// Currently: a sending can't create from sending list +// $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; +// if (!empty($socid)) $url .= '&socid='.$socid; +// $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); +$newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); + +$i = 0; +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); + +$topicmail = "SendShippingRef"; +$modelmail = "shipping_send"; +$objecttmp = new Expedition($db); +$trackid = 'shi'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; +} - // Currently: a sending can't create from sending list - // $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; - // if (!empty($socid)) $url .= '&socid='.$socid; - // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); - $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); +$moreforfilter = ''; - $i = 0; - print ''."\n"; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; +// If the user can view prospects other than his' +if ($user->rights->societe->client->voir || $socid) { + $langs->load("commercial"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; +} +// If the user can view other users +if ($user->rights->user->user->lire) { + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; +} +// If the user can view prospects other than his' +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; +} +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '
'; +} +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} - print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} - $topicmail = "SendShippingRef"; - $modelmail = "shipping_send"; - $objecttmp = new Expedition($db); - $trackid = 'shi'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); +if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields +} - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; - } +print '
'; +print ''."\n"; - $moreforfilter = ''; +// Fields title search +print ''; +// Ref +if (!empty($arrayfields['e.ref']['checked'])) { + print ''; +} +// Ref customer +if (!empty($arrayfields['e.ref_customer']['checked'])) { + print ''; +} +// Thirdparty +if (!empty($arrayfields['s.nom']['checked'])) { + print ''; +} +// Town +if (!empty($arrayfields['s.town']['checked'])) { + print ''; +} +// Zip +if (!empty($arrayfields['s.zip']['checked'])) { + print ''; +} +// State +if (!empty($arrayfields['state.nom']['checked'])) { + print ''; +} +// Country +if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; +} +// Company type +if (!empty($arrayfields['typent.code']['checked'])) { + print ''; +} +// Weight +if (!empty($arrayfields['e.weight']['checked'])) { + print ''; +} +// Date delivery planned +if (!empty($arrayfields['e.date_delivery']['checked'])) { + print ''; +} +// Tracking number +if (!empty($arrayfields['e.tracking_number']['checked'])) { + print ''; +} +if (!empty($arrayfields['l.ref']['checked'])) { + // Delivery ref + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; - } +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (!empty($arrayfields['e.datec']['checked'])) { + print ''; +} +// Date modification +if (!empty($arrayfields['e.tms']['checked'])) { + print ''; +} +// Status +if (!empty($arrayfields['e.fk_statut']['checked'])) { + print ''; +} +// Status billed +if (!empty($arrayfields['e.billed']['checked'])) { + print ''; +} +// Action column +print ''; +print "\n"; - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); - if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields - } +print ''; +if (!empty($arrayfields['e.ref']['checked'])) { + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['e.ref_customer']['checked'])) { + print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); +} +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, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.weight']['checked'])) { + print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['e.tracking_number']['checked'])) { + print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['l.ref']['checked'])) { + print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['l.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$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['e.datec']['checked'])) { + print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['e.tms']['checked'])) { + print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['e.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['e.billed']['checked'])) { + print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); +} +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; - print '
'; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print ''; - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { - $langs->load("commercial"); - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter .= '
'; - } - // If the user can view other users - if ($user->rights->user->user->lire) { - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter .= '
'; - } - // If the user can view prospects other than his' - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter .= '
'; - } - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter .= '
'; - } - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + print ''; +} +if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print ''; + print '
'; + print $form->selectDate($search_datereceipt_start ? $search_datereceipt_start : -1, 'search_datereceipt_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datereceipt_end ? $search_datereceipt_end : -1, 'search_datereceipt_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1); + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); + print ''; +$searchpicto = $form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '
'."\n"; +$typenArray = $formcompany->typent_array(1); +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $obj = $db->fetch_object($resql); + + $shipment->id = $obj->rowid; + $shipment->ref = $obj->ref; + + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; + + $object = new Expedition($db); + $object->fetch($obj->rowid); + + print ''; - // Fields title search - print ''; // Ref if (!empty($arrayfields['e.ref']['checked'])) { - print ''; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } + // Ref customer if (!empty($arrayfields['e.ref_customer']['checked'])) { - print ''; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - // Thirdparty + + // Third party if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // State if (!empty($arrayfields['state.nom']['checked'])) { - print ''; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } // Country if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - // Company type + // Type ent if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print ''; - } - // Date delivery planned - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print ''; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print ''; - } - if (!empty($arrayfields['l.ref']['checked'])) { - // Delivery ref - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print ''; - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print ''; - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - } - // Status billed - if (!empty($arrayfields['e.billed']['checked'])) { - print ''; - } - // Action column - print ''; - print "\n"; - - print ''; - if (!empty($arrayfields['e.ref']['checked'])) { - print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - } - 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, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.weight']['checked'])) { - print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print_liste_field_titre($arrayfields['e.tracking_number']['label'], $_SERVER["PHP_SELF"], "e.tracking_number", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['l.ref']['checked'])) { - print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['l.date_delivery']['checked'])) { - print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $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['e.datec']['checked'])) { - print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - if (!empty($arrayfields['e.tms']['checked'])) { - print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - } - if (!empty($arrayfields['e.billed']['checked'])) { - print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); - } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - print "\n"; - - $typenArray = $formcompany->typent_array(1); - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - - $shipment->id = $obj->rowid; - $shipment->ref = $obj->ref; - - $companystatic->id = $obj->socid; - $companystatic->ref = $obj->name; - $companystatic->name = $obj->name; - - $object = new Expedition($db); - $object->fetch($obj->rowid); - - print ''; - - // Ref - if (!empty($arrayfields['e.ref']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery planed - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print '\n"; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { - $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving = ''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { - $receiving = reset($shipment->linkedObjects['delivery']); - } - - if (!empty($arrayfields['l.ref']['checked'])) { - // Ref - print ''; - } - - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print ''."\n"; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['e.billed']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - print ''; if (!$i) { $totalarray['nbfield']++; } - - print "\n"; - - $i++; } - $db->free($resql); + // Weight + if (!empty($arrayfields['e.weight']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery planed + if (!empty($arrayfields['e.date_delivery']['checked'])) { + print '\n"; + } + // Tracking number + if (!empty($arrayfields['e.tracking_number']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } - $parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { + $shipment->fetchObjectLinked($shipment->id, $shipment->element); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { + $receiving = reset($shipment->linkedObjects['delivery']); + } + + if (!empty($arrayfields['l.ref']['checked'])) { + // Ref + print ''; + } + + if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print ''."\n"; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - - print "
'; - print ''; - print '"; + print $shipment->getNomUrl(1); + print "'; - print ''; - print '"; + print $obj->ref_customer; + print "'; - print ''; + print ''; + print $companystatic->getNomUrl(1); print ''; + print $obj->town; + print ''; + print $obj->zip; + print ''; - print ''; - print '".$obj->state_name."'; - print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); - print ''; - - print ''; - print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_delivery_start ? $search_delivery_start : -1, 'search_delivery_start', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_delivery_end ? $search_delivery_end : -1, 'search_delivery_end', 0, 0, 1); - print '
'; - print '
'; - print ''; - print ''; - print ''; - } - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print ''; - print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_receipt_start ? $search_receipt_start : -1, 'search_receipt_start', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_receipt_end ? $search_receipt_end : -1, 'search_receipt_end', 0, 0, 1); - print '
'; - print '
'; - print ''; - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1); - print ''; - print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
"; - print $shipment->getNomUrl(1); - print ""; - print $obj->ref_customer; - print "'; - print $companystatic->getNomUrl(1); - print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (isset($typenArray[$obj->typent_code])) { - print $typenArray[$obj->typent_code]; - } - print ''; - if (empty($object->trueWeight)) { - $tmparray = $object->getTotalWeightVolume(); - print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - print ''; - print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); - /*$now = time(); - if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 ) - { - }*/ - print "'.$obj->tracking_number."'; - print !empty($receiving) ? $receiving->getNomUrl($db) : ''; - print ''; - print dol_print_date($db->jdate($obj->date_reception), "day"); - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$shipment->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + print ''; + if (isset($typenArray[$obj->typent_code])) { + print $typenArray[$obj->typent_code]; } print '
'; + if (empty($object->trueWeight)) { + $tmparray = $object->getTotalWeightVolume(); + print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + print ''; + print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); + /*$now = time(); + if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 ) + { + }*/ + print "'.$obj->tracking_number."'; + print !empty($receiving) ? $receiving->getNomUrl($db) : ''; + print ''; + print dol_print_date($db->jdate($obj->date_reception), "day"); + print '
"; - print "
"; - print ''; - - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; + // Date creation + if (!empty($arrayfields['e.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['e.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['e.fk_statut']['checked'])) { + print ''.$shipment->LibStatut($obj->fk_statut, 5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['e.billed']['checked'])) { + print ''.yn($obj->billed).''; + if (!$i) { + $totalarray['nbfield']++; + } } - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); + // Action column + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } - $filedir = $diroutputmassaction; - $genallowed = $user->rights->expedition->lire; - $delallowed = $user->rights->expedition->creer; - $title = ''; + print "\n"; - print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} else { - dol_print_error($db); + $i++; } +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'totalarray' => $totalarray, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ""; +print "
"; +print ''; + +$hidegeneratedfilelistifempty = 1; +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; +} + +// Show list of available documents +$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; +$urlsource .= str_replace('&', '&', $param); + +$filedir = $diroutputmassaction; +$genallowed = $user->rights->expedition->lire; +$delallowed = $user->rights->expedition->creer; +$title = ''; + +print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 1d7f5cce418..3b9a0df399b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -99,7 +99,7 @@ if (empty($reshook)) { if ($action == 'setsupplieraccountancycode') { $result = $object->fetch($id); - $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); $result = $object->update($object->id, $user, 1, 0, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -195,7 +195,7 @@ if ($object->id > 0) { print '
'; print '
'; - print ''; + print '
'; // Type Prospect/Customer/Supplier print ''; print ''; // Default terms of the settlement diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index e0eea961b9e..db2b6dd749a 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -952,7 +952,7 @@ class ProductFournisseur extends Product } $out .= '
'.$langs->trans('NatureOfThirdParty').''; @@ -209,7 +209,7 @@ if ($object->id > 0) { if ($object->fournisseur) { print '
'.$langs->trans("SupplierCode").''; - print $object->code_fournisseur; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -250,7 +250,7 @@ if ($object->id > 0) { // TVA Intra print '
'.$langs->trans('VATIntra').''; - print $object->tva_intra; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); print '
'; } else { - $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); + $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? ''.$langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); } return $out; } diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index 254fac29f28..fd15894b4ec 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -93,9 +93,7 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr $row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_")); //create new select2 to avoid duplicate id of cloned one diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index 6a51d6d0a88..85039a3e6e1 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->loadLangs(array("admin", "ftp")); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $def = array(); $lastftpentry = 0; @@ -45,36 +47,33 @@ $entry = GETPOST('numero_entry', 'alpha'); $sql = "select MAX(name) as name from ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name like 'FTP_SERVER_%'"; $result = $db->query($sql); -if ($result) -{ +if ($result) { $obj = $db->fetch_object($result); preg_match('/([0-9]+)$/i', $obj->name, $reg); - if ($reg[1]) $lastftpentry = $reg[1]; + if ($reg[1]) { + $lastftpentry = $reg[1]; + } } else { dol_print_error($db); } -if ($action == 'add' || GETPOST('modify', 'alpha')) -{ +if ($action == 'add' || GETPOST('modify', 'alpha')) { $ftp_name = "FTP_NAME_".$entry; // $_POST["numero_entry"]; $ftp_server = "FTP_SERVER_".$entry; //$_POST["numero_entry"]; $error = 0; - if (!GETPOST("$ftp_name", 'alpha')) - { + if (!GETPOST("$ftp_name", 'alpha')) { $error = 1; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } - if (!GETPOST("$ftp_server", 'alpha')) - { + if (!GETPOST("$ftp_server", 'alpha')) { $error = 1; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server")), null, 'errors'); } - if (!$error) - { + if (!$error) { $ftp_port = "FTP_PORT_".$entry; $ftp_user = "FTP_USER_".$entry; $ftp_password = "FTP_PASSWORD_".$entry; @@ -83,14 +82,23 @@ if ($action == 'add' || GETPOST('modify', 'alpha')) $db->begin(); $result1 = dolibarr_set_const($db, "FTP_PORT_".$entry, GETPOST($ftp_port, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result1) $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result2) $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result3) $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result4) $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result5) $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity); + if ($result1) { + $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result2) { + $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result3) { + $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result4) { + $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity); + } + if ($result5) { + $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity); + } - if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) - { + if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -101,21 +109,28 @@ if ($action == 'add' || GETPOST('modify', 'alpha')) } } -if (GETPOST('delete', 'alpha')) -{ - if ($entry) - { +if (GETPOST('delete', 'alpha')) { + if ($entry) { $db->begin(); $result1 = dolibarr_del_const($db, "FTP_PORT_".$entry, $conf->entity); - if ($result1) $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity); - if ($result2) $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity); - if ($result3) $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity); - if ($result4) $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity); - if ($result4) $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity); + if ($result1) { + $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity); + } + if ($result2) { + $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity); + } + if ($result3) { + $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity); + } + if ($result4) { + $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity); + } + if ($result4) { + $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity); + } - if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) - { + if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -139,8 +154,7 @@ $linkback = ''; -if (!function_exists('ftp_connect')) -{ +if (!function_exists('ftp_connect')) { print $langs->trans("FTPFeatureNotSupportedByYourPHP"); } else { // Formulaire ajout @@ -186,7 +200,9 @@ if (!function_exists('ftp_connect')) print ''; print ''.$langs->trans("FTPPassiveMode").''; $defaultpassive = GETPOST("FTP_PASSIVE_".($lastftpentry + 1)); - if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1; + if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) { + $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1; + } print ''.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry + 1), $defaultpassive, 2).''; print ''.$langs->trans("No").''; print ''; @@ -211,13 +227,11 @@ if (!function_exists('ftp_connect')) dol_syslog("ftpclient select ftp setup", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); preg_match('/([0-9]+)$/i', $obj->name, $reg); diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 51a8028e1f3..3f04f161038 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -32,13 +32,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; $langs->loadLangs(array('ftp', 'companies', 'other')); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'ftp', ''); // Get parameters $action = GETPOST('action', 'aZ09'); $section = GETPOST('section'); -if (!$section) $section = '/'; +if (!$section) { + $section = '/'; +} $numero_ftp = GETPOST("numero_ftp"); /* if (! $numero_ftp) $numero_ftp=1; */ $file = GETPOST("file"); @@ -51,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "label"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "label"; +} $s_ftp_name = 'FTP_NAME_'.$numero_ftp; $s_ftp_server = 'FTP_SERVER_'.$numero_ftp; @@ -66,7 +76,9 @@ $s_ftp_password = 'FTP_PASSWORD_'.$numero_ftp; $s_ftp_passive = 'FTP_PASSIVE_'.$numero_ftp; $ftp_name = $conf->global->$s_ftp_name; $ftp_server = $conf->global->$s_ftp_server; -$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) $ftp_port = 21; +$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) { + $ftp_port = 21; +} $ftp_user = $conf->global->$s_ftp_user; $ftp_password = $conf->global->$s_ftp_password; $ftp_passive = $conf->global->$s_ftp_passive; @@ -83,29 +95,24 @@ $mesg = ''; */ // Submit file -if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) -{ +if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $result = $ecmdir->fetch(GETPOST("section", 'int')); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - if (dol_mkdir($upload_dir) >= 0) - { + if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0); - if (is_numeric($resupload) && $resupload > 0) - { + if (is_numeric($resupload) && $resupload > 0) { $result = $ecmdir->changeNbOfFiles('+'); } else { $langs->load("errors"); - if ($resupload < 0) // Unknown error - { + if ($resupload < 0) { // Unknown error setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { // Files infected by a virus @@ -123,15 +130,13 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) } // Action ajout d'un rep -if ($action == 'add' && $user->rights->ftp->setup) -{ +if ($action == 'add' && $user->rights->ftp->setup) { $ecmdir->ref = GETPOST("ref"); $ecmdir->label = GETPOST("label"); $ecmdir->description = GETPOST("desc"); $id = $ecmdir->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -141,11 +146,9 @@ if ($action == 'add' && $user->rights->ftp->setup) } // Remove 1 file -if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') -{ +if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -153,11 +156,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -175,8 +176,7 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') } else { $result = @ftp_delete($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs'); } else { dol_syslog("ftp/index.php ftp_delete", LOG_ERR); @@ -192,11 +192,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') } // Delete several lines at once -if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) -{ +if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -204,19 +202,15 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { - foreach (GETPOST('const', 'array') as $const) - { - if ($const["check"]) // Is checkbox checked - { + if ($conn_id && $ok && !$mesg) { + foreach (GETPOST('const', 'array') as $const) { + if ($const["check"]) { // Is checkbox checked $langs->load("other"); // Remote file $file = $const["file"]; $newsection = $const["section"]; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; @@ -229,8 +223,7 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang } else { $result = @ftp_delete($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs'); } else { dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR); @@ -248,11 +241,9 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang } // Remove directory -if ($action == 'confirm_deletesection' && $confirm == 'yes') -{ +if ($action == 'confirm_deletesection' && $confirm == 'yes') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -260,11 +251,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -278,8 +267,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') } else { $result = @ftp_rmdir($conn_id, $newremotefileiso); } - if ($result) - { + if ($result) { setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs'); } else { setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors'); @@ -294,11 +282,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes') } // Download directory -if ($action == 'download') -{ +if ($action == 'download') { // set up a connection or die - if (!$conn_id) - { + if (!$conn_id) { $newsectioniso = utf8_decode($section); $resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive); $conn_id = $resultarray['conn_id']; @@ -306,14 +292,12 @@ if ($action == 'download') $mesg = $resultarray['mesg']; } - if ($conn_id && $ok && !$mesg) - { + if ($conn_id && $ok && !$mesg) { // Local file $localfile = tempnam($download_dir, 'dol_'); $newsection = $section; - if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) - { + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 } @@ -327,23 +311,31 @@ if ($action == 'download') } else { $result = ftp_get($conn_id, $localfile, $newremotefileiso, FTP_BINARY); } - if ($result) - { - if (!empty($conf->global->MAIN_UMASK)) - @chmod($localfile, octdec($conf->global->MAIN_UMASK)); + if ($result) { + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($localfile, octdec($conf->global->MAIN_UMASK)); + } // Define mime type $type = 'application/octet-stream'; - if (GETPOSTISSET("type")) $type = GETPOST("type"); - else $type = dol_mimetype($file); + if (GETPOSTISSET("type")) { + $type = GETPOST("type"); + } else { + $type = dol_mimetype($file); + } // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); + if ($type) { + header('Content-Type: '.$type); + } + if ($attachment) { + header('Content-Disposition: attachment; filename="'.$filename.'"'); + } else { + header('Content-Disposition: inline; filename="'.$filename.'"'); + } // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); @@ -374,8 +366,7 @@ if ($action == 'download') llxHeader(); // Add logic to shoow/hide buttons -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { ?> '; + print ''.$langs->trans("ShowHideDetails").''; + //} + + print ''."\n"; + print ''; + } + + //print '

'.$langs->trans("MigrationFinished").'
'; } else { print '
'.$langs->trans('ErrorWrongParameters').'
'; $error++; @@ -4296,7 +4333,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod = new $classname($db); //$mod->remove('noboxes'); - $mod->delete_menus(); // We must delete to be sure it is insert with new values + $mod->delete_menus(); // We must delete to be sure it is inserted with new values $mod->init($reloadmode); } else { dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); @@ -4320,7 +4357,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } if (!empty($mod) && is_object($mod)) { - print ''; + print ''; print ''.$langs->trans('Upgrade').': '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated print ""; @@ -4355,7 +4392,7 @@ function migrate_reload_menu($db, $langs, $conf) } foreach ($listofmenuhandler as $key => $val) { - print ''; + print ''; //print "x".$key; print '
'; diff --git a/htdocs/intracommreport/admin/intracommreport.php b/htdocs/intracommreport/admin/intracommreport.php index 16e24503959..c696dddcabd 100644 --- a/htdocs/intracommreport/admin/intracommreport.php +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "intracommreport")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -46,10 +48,8 @@ $list_DES = array( if ($action == 'update') { $error = 0; - if (!$error) - { - foreach ($list_DEB as $constname) - { + if (!$error) { + foreach ($list_DEB as $constname) { $constvalue = GETPOST($constname, 'alpha'); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { @@ -57,8 +57,7 @@ if ($action == 'update') { } } - foreach ($list_DES as $constname) - { + foreach ($list_DES as $constname) { $constvalue = GETPOST($constname, 'alpha'); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { @@ -110,8 +109,7 @@ print ''.$langs->trans("Description").''; print ''.$langs->trans("Value").''; print ''; -foreach ($list_DEB as $key) -{ +foreach ($list_DEB as $key) { print ''; // Param @@ -175,8 +173,7 @@ print ''.$langs->trans("Description").''; print ''.$langs->trans("Value").''; print ''; -foreach ($list_DES as $key) -{ +foreach ($list_DES as $key) { print ''; // Param diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index d4c9f95b0b9..42180dde04f 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -172,13 +172,13 @@ ProfId1ES=Prof Id 1 (CIF/NIF) ProfId2ES=Prof Id 2 (Social security number) ProfId3ES=Prof Id 3 (CNAE) ProfId4ES=Prof Id 4 (Collegiate number) -ProfId5ES=EORI number +ProfId5ES=Prof Id 5 (EORI number) ProfId6ES=- ProfId1FR=Prof Id 1 (SIREN) ProfId2FR=Prof Id 2 (SIRET) ProfId3FR=Prof Id 3 (NAF, old APE) ProfId4FR=Prof Id 4 (RCS/RM) -ProfId5FR=EORI number +ProfId5FR=Prof Id 5 (numéro EORI) ProfId6FR=- ProfId1GB=Registration Number ProfId2GB=- @@ -232,7 +232,7 @@ ProfId1PT=Prof Id 1 (NIPC) ProfId2PT=Prof Id 2 (Social security number) ProfId3PT=Prof Id 3 (Commercial Record number) ProfId4PT=Prof Id 4 (Conservatory) -ProfId5PT=EORI number +ProfId5PT=Prof Id 5 (EORI number) ProfId6PT=- ProfId1SN=RC ProfId2SN=NINEA @@ -256,7 +256,7 @@ ProfId1RO=Prof Id 1 (CUI) ProfId2RO=Prof Id 2 (Nr. Înmatriculare) ProfId3RO=Prof Id 3 (CAEN) ProfId4RO=Prof Id 5 (EUID) -ProfId5RO=EORI number +ProfId5RO=Prof Id 5 (EORI number) ProfId6RO=- ProfId1RU=Prof Id 1 (OGRN) ProfId2RU=Prof Id 2 (INN) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 5ca0dbc6981..fceeb1a15f1 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -89,7 +89,7 @@ ConfirmEnableWorkstation=Are you sure you want to enable workstation %s ? EnableAWorkstation=Enable a workstation ConfirmDisableWorkstation=Are you sure you want to disable workstation %s ? DisableAWorkstation=Disable a workstation -DeleteWorkstation=Supprimer +DeleteWorkstation=Delete NbOperatorsRequired=Number of operators required THMOperatorEstimated=Estimated operator THM THMMachineEstimated=Estimated machine THM diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 54270c4a23b..3ab83908ff5 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,8 +1,10 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Use lot/serial number -ProductStatusOnBatch=Yes (lot/serial required) +ProductStatusOnBatch=Yes (lot required) +ProductStatusOnSerial=Yes (unique serial number required) ProductStatusNotOnBatch=No (lot/serial not used) -ProductStatusOnBatchShort=Yes +ProductStatusOnBatchShort=Lot +ProductStatusOnSerialShort=Serial ProductStatusNotOnBatchShort=No Batch=Lot/Serial atleast1batchfield=Eat-by date or Sell-by date or Lot/Serial number diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 162af66827c..76cba909e2c 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -1,8 +1,10 @@ # ProductBATCH language file - en_US - ProductBATCH ManageLotSerial=Utiliser les numéros de lots/série -ProductStatusOnBatch=Oui (Lot/Série requis) +ProductStatusOnBatch=Lot (requis) +ProductStatusOnSerial=Numéro de série (doit être unique pour chaque équipement) ProductStatusNotOnBatch=Non (Lot/Série non utilisé) -ProductStatusOnBatchShort=Oui +ProductStatusOnBatchShort=Lot +ProductStatusOnSerialShort=N°série ProductStatusNotOnBatchShort=Non Batch=Lot/Série atleast1batchfield=Date limite utilisation optimale, de consommation ou numéro de lot/série diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index d5f9704addc..5c6260dec84 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -24,9 +24,15 @@ * \brief File to calculate loan monthly payments */ -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 1143fbcd474..9e9e1a0a992 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -28,8 +28,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +} +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +} require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -45,7 +49,9 @@ $projectid = GETPOST('projectid', 'int'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); @@ -60,16 +66,15 @@ $error = 0; */ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { // Classify paid - if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) - { + if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setPaid($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); } else { setEventMessages($loan->error, null, 'errors'); @@ -77,12 +82,10 @@ if (empty($reshook)) } // Delete loan - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) - { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) { $object->fetch($id); $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); header("Location: list.php"); exit; @@ -92,44 +95,37 @@ if (empty($reshook)) } // Add loan - if ($action == 'add' && $user->rights->loan->write) - { - if (!$cancel) - { + if ($action == 'add' && $user->rights->loan->write) { + if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int')); $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int')); $capital = price2num(GETPOST('capital')); $rate = GETPOST('rate'); - if (!$capital) - { + if (!$capital) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); } - if (!$datestart) - { + if (!$datestart) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); } - if (!$dateend) - { + if (!$dateend) { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); } - if ($rate == '') - { + if ($rate == '') { $error++; $action = 'create'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors'); } - if (!$error) - { + if (!$error) { $object->label = GETPOST('label'); - $object->fk_bank = GETPOST('accountid'); - $object->capital = $capital; + $object->fk_bank = GETPOST('accountid'); + $object->capital = $capital; $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = GETPOST('nbterm'); + $object->dateend = $dateend; + $object->nbterm = GETPOST('nbterm'); $object->rate = $rate; $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -140,13 +136,24 @@ if (empty($reshook)) $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); $accountancy_account_interest = GETPOST('accountancy_account_interest'); - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + if ($accountancy_account_capital <= 0) { + $object->account_capital = ''; + } else { + $object->account_capital = $accountancy_account_capital; + } + if ($accountancy_account_insurance <= 0) { + $object->account_insurance = ''; + } else { + $object->account_insurance = $accountancy_account_insurance; + } + if ($accountancy_account_interest <= 0) { + $object->account_interest = ''; + } else { + $object->account_interest = $accountancy_account_interest; + } $id = $object->create($user); - if ($id <= 0) - { + if ($id <= 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; @@ -156,21 +163,16 @@ if (empty($reshook)) header("Location: list.php"); exit(); } - } - - // Update record - elseif ($action == 'update' && $user->rights->loan->write) - { - if (!$cancel) - { + } elseif ($action == 'update' && $user->rights->loan->write) { + // Update record + if (!$cancel) { $result = $object->fetch($id); $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int')); $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int')); $capital = price2num(GETPOST('capital')); - if (!$capital) - { + if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); $action = 'edit'; } else { @@ -185,15 +187,26 @@ if (empty($reshook)) $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); $accountancy_account_interest = GETPOST('accountancy_account_interest'); - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + if ($accountancy_account_capital <= 0) { + $object->account_capital = ''; + } else { + $object->account_capital = $accountancy_account_capital; + } + if ($accountancy_account_insurance <= 0) { + $object->account_insurance = ''; + } else { + $object->account_insurance = $accountancy_account_insurance; + } + if ($accountancy_account_interest <= 0) { + $object->account_interest = ''; + } else { + $object->account_interest = $accountancy_account_interest; + } } $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { @@ -207,20 +220,20 @@ if (empty($reshook)) } // Link to a project - if ($action == 'classin' && $user->rights->loan->write) - { + if ($action == 'classin' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setProject($projectid); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + } } - if ($action == 'setlabel' && $user->rights->loan->write) - { + if ($action == 'setlabel' && $user->rights->loan->write) { $object->fetch($id); $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } } @@ -231,7 +244,9 @@ if (empty($reshook)) $form = new Form($db); $formproject = new FormProjets($db); -if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); +} $title = $langs->trans("Loan").' - '.$langs->trans("Card"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; @@ -239,8 +254,7 @@ llxHeader("", $title, $help_url); // Create mode -if ($action == 'create') -{ +if ($action == 'create') { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -260,8 +274,7 @@ if ($action == 'create') print ''.$langs->trans("Label").''; // Bank account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''.$langs->trans("Account").''; $form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant print ''; @@ -296,8 +309,7 @@ if ($action == 'create') print ''.$langs->trans("Insurance").''; // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); // Projet associe @@ -329,8 +341,7 @@ if ($action == 'create') print ''; // Accountancy - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { // Accountancy_account_capital print ''.$langs->trans("LoanAccountancyCapitalCode").''; print ''; @@ -379,32 +390,27 @@ if ($action == 'create') } // View -if ($id > 0) -{ +if ($id > 0) { $object = new Loan($db); $result = $object->fetch($id); - if ($result > 0) - { + if ($result > 0) { $head = loan_prepare_head($object); $totalpaid = $object->getSumPayment(); // Confirm for loan - if ($action == 'paid') - { + if ($action == 'paid') { $text = $langs->trans('ConfirmPayLoan'); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayLoan'), $text, "confirm_paid", '', '', 2); } - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteLoan'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteLoan'), $text, 'confirm_delete', '', '', 2); } - if ($action == 'edit') - { + if ($action == 'edit') { print '
'."\n"; print ''; print ''; @@ -422,14 +428,13 @@ if ($id > 0) $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->loan->write) - { - if ($action != 'classify') + if ($user->rights->loan->write) { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= ''; @@ -466,8 +471,7 @@ if ($id > 0) print ''; // Capital - if ($action == 'edit') - { + if ($action == 'edit') { print ''; print ''; @@ -476,8 +480,7 @@ if ($id > 0) } // Insurance - if ($action == 'edit') - { + if ($action == 'edit') { print ''; print ''; @@ -488,8 +491,7 @@ if ($id > 0) // Date start print '"; print ""; print "'; print ''; print ''; - if ($action == 'edit') - { + if ($action == 'edit') { print ''; - if ($action == 'edit') - { + if ($action == 'edit') { print ''; - if ($action == 'edit') - { + if ($action == 'edit') { print ''; print ''; - while ($i < $num) - { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -690,8 +678,7 @@ if ($id > 0) $totalpaid = $total_capital; - if ($object->paid == 0 || $object->paid == 2) - { + if ($object->paid == 0 || $object->paid == 2) { print ''; print ''; @@ -718,8 +705,7 @@ if ($id > 0) print dol_get_fiche_end(); - if ($action == 'edit') - { + if ($action == 'edit') { print '
'; print ''; print '     '; @@ -732,34 +718,28 @@ if ($id > 0) /* * Buttons actions */ - if ($action != 'edit') - { + if ($action != 'edit') { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) - { + if (empty($reshook)) { print '
'; // Edit - if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) { print ''; } // Emit payment - if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { print ''; } // Classify 'paid' - if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) - { + if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) { print ''; } // Delete - if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) - { + if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) { print ''; } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 9f2d8297edc..c82be7848a6 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -135,10 +135,8 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -188,36 +186,52 @@ class Loan extends CommonObject // clean parameters $newcapital = price2num($this->capital, 'MT'); - if (empty($this->insurance_amount)) $this->insurance_amount = 0; + if (empty($this->insurance_amount)) { + $this->insurance_amount = 0; + } $newinsuranceamount = price2num($this->insurance_amount, 'MT'); - if (isset($this->note_private)) $this->note_private = trim($this->note_private); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital); - if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance); - if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest); - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; - if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project; + if (isset($this->note_private)) { + $this->note_private = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note_public = trim($this->note_public); + } + if (isset($this->account_capital)) { + $this->account_capital = trim($this->account_capital); + } + if (isset($this->account_insurance)) { + $this->account_insurance = trim($this->account_insurance); + } + if (isset($this->account_interest)) { + $this->account_interest = trim($this->account_interest); + } + if (isset($this->fk_bank)) { + $this->fk_bank = (int) $this->fk_bank; + } + if (isset($this->fk_user_creat)) { + $this->fk_user_creat = (int) $this->fk_user_creat; + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = (int) $this->fk_user_modif; + } + if (isset($this->fk_project)) { + $this->fk_project = (int) $this->fk_project; + } // Check parameters - if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) - { + if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) { $this->error = "ErrorBadParameter"; return -2; } - if (($conf->accounting->enabled) && empty($this->account_capital)) - { + if (($conf->accounting->enabled) && empty($this->account_capital)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode")); return -2; } - if (($conf->accounting->enabled) && empty($this->account_insurance)) - { + if (($conf->accounting->enabled) && empty($this->account_insurance)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode")); return -2; } - if (($conf->accounting->enabled) && empty($this->account_interest)) - { + if (($conf->accounting->enabled) && empty($this->account_interest)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode")); return -2; } @@ -248,8 +262,7 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan"); //dol_syslog("Loans::create this->id=".$this->id); @@ -281,47 +294,39 @@ class Loan extends CommonObject $lines_url = $account->get_url('', $this->id, 'loan'); // Delete bank urls - foreach ($lines_url as $line_url) - { - if (!$error) - { + foreach ($lines_url as $line_url) { + if (!$error) { $accountline = new AccountLine($this->db); $accountline->fetch($line_url['fk_bank']); $result = $accountline->delete_urls($user); - if ($result < 0) - { + if ($result < 0) { $error++; } } } // Delete payments - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -341,8 +346,7 @@ class Loan extends CommonObject { $this->db->begin(); - if (!is_numeric($this->nbterm)) - { + if (!is_numeric($this->nbterm)) { $this->error = 'BadValueForParameterForNbTerm'; return -1; } @@ -364,8 +368,7 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; } else { @@ -512,22 +515,29 @@ class Loan extends CommonObject $langs->loadLangs(array("customers", "bills")); unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); $this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); - if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) { + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); $this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted"); - if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) { + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } } $statusType = 'status1'; - if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) $statusType = 'status3'; - if ($status == 1) $statusType = 'status6'; + if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) { + $statusType = 'status3'; + } + if ($status == 1) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -560,33 +570,40 @@ class Loan extends CommonObject $url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id; - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + } $result .= $linkend; return $result; @@ -638,12 +655,13 @@ class Loan extends CommonObject dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $amount = 0; $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + if ($obj) { + $amount = $obj->amount ? $obj->amount : 0; + } $this->db->free($resql); return $amount; @@ -668,26 +686,24 @@ class Loan extends CommonObject dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_modif) - { + if ($obj->fk_user_modif) { $muser = new User($this->db); $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } $this->date_creation = $this->db->jdate($obj->datec); - if (empty($obj->fk_user_modif)) $obj->tms = ""; + if (empty($obj->fk_user_modif)) { + $obj->tms = ""; + } $this->date_modification = $this->db->jdate($obj->tms); $this->db->free($result); diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 50339359a9d..4f6f1423aa7 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -129,21 +129,36 @@ class LoanSchedule extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datep) - { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameter'; return -1; } // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0); - if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0); - if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0); - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + if (isset($this->amount_capital)) { + $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0); + } + if (isset($this->amount_interest)) { + $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0); + } + if (isset($this->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + if (isset($this->fk_bank)) { + $this->fk_bank = (int) $this->fk_bank; + } + if (isset($this->fk_user_creat)) { + $this->fk_user_creat = (int) $this->fk_user_creat; + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = (int) $this->fk_user_modif; + } $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; $totalamount = price2num($totalamount); @@ -157,8 +172,7 @@ class LoanSchedule extends CommonObject $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; $sql .= " fk_typepayment, fk_user_creat, fk_bank)"; $sql .= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',"; @@ -172,8 +186,7 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); } else { $this->error = $this->db->lasterror(); @@ -181,8 +194,7 @@ class LoanSchedule extends CommonObject } } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount_capital = $totalamount; $this->db->commit(); return $this->id; @@ -280,14 +292,30 @@ class LoanSchedule extends CommonObject $error = 0; // Clean parameters - if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital); - if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance); - if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest); - if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); - if (isset($this->note_private)) $this->note_private = trim($this->note_private); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); - if (isset($this->fk_payment_loan)) $this->fk_payment_loan = (int) $this->fk_payment_loan; + if (isset($this->amount_capital)) { + $this->amount_capital = trim($this->amount_capital); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = trim($this->amount_insurance); + } + if (isset($this->amount_interest)) { + $this->amount_interest = trim($this->amount_interest); + } + if (isset($this->num_payment)) { + $this->num_payment = trim($this->num_payment); + } + if (isset($this->note_private)) { + $this->note_private = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note_public = trim($this->note_public); + } + if (isset($this->fk_bank)) { + $this->fk_bank = trim($this->fk_bank); + } + if (isset($this->fk_payment_loan)) { + $this->fk_payment_loan = (int) $this->fk_payment_loan; + } // Check parameters // Put here code to add control on parameters values @@ -317,11 +345,12 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback - if ($error) - { + if ($error) { $this->db->rollback(); return -1 * $error; } else { @@ -351,14 +380,14 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -423,10 +452,8 @@ class LoanSchedule extends CommonObject dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $line = new LoanSchedule($this->db); $line->id = $obj->rowid; $line->ref = $obj->rowid; @@ -537,14 +564,15 @@ class LoanSchedule extends CommonObject $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; $sql .= " WHERE p.fk_loan = ".$loanid; - if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; } + if (!empty($datemax)) { + $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; + } $sql .= " AND p.datep <= '".$this->db->idate(dol_now())."'"; $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $result[] = $obj->rowid; } } diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index aa3f895f314..1ca8e1c0a4d 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -126,36 +126,58 @@ class PaymentLoan extends CommonObject $now = dol_now(); // Validate parameters - if (!$this->datep) - { + if (!$this->datep) { $this->error = 'ErrorBadValueForParameter'; return -1; } // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - if (isset($this->amount_capital)) $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); - if (isset($this->amount_insurance)) $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); - if (isset($this->amount_interest)) $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment; - if (isset($this->note_private)) $this->note_private = trim($this->note_private); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + if (isset($this->amount_capital)) { + $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0); + } + if (isset($this->amount_interest)) { + $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0); + } + if (isset($this->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + if (isset($this->num_payment)) { + $this->num_payment = (int) $this->num_payment; + } + if (isset($this->note_private)) { + $this->note_private = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note_public = trim($this->note_public); + } + if (isset($this->fk_bank)) { + $this->fk_bank = (int) $this->fk_bank; + } + if (isset($this->fk_user_creat)) { + $this->fk_user_creat = (int) $this->fk_user_creat; + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = (int) $this->fk_user_modif; + } $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; $totalamount = price2num($totalamount); // Check parameters - if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null + if ($totalamount == 0) { + return -1; // Negative amounts are accepted for reject prelevement but not null + } $this->db->begin(); - if ($totalamount != 0) - { + if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; $sql .= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)"; $sql .= " VALUES (".$this->chid.", '".$this->db->idate($now)."',"; @@ -168,8 +190,7 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); } else { $this->error = $this->db->lasterror(); @@ -177,8 +198,7 @@ class PaymentLoan extends CommonObject } } - if ($totalamount != 0 && !$error) - { + if ($totalamount != 0 && !$error) { $this->amount_capital = $totalamount; $this->db->commit(); return $this->id; @@ -223,10 +243,8 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -276,17 +294,39 @@ class PaymentLoan extends CommonObject $error = 0; // Clean parameters - if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan; - if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital); - if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance); - if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest); - if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; - if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment; - if (isset($this->note_private)) $this->note = trim($this->note_private); - if (isset($this->note_public)) $this->note = trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; + if (isset($this->fk_loan)) { + $this->fk_loan = (int) $this->fk_loan; + } + if (isset($this->amount_capital)) { + $this->amount_capital = trim($this->amount_capital); + } + if (isset($this->amount_insurance)) { + $this->amount_insurance = trim($this->amount_insurance); + } + if (isset($this->amount_interest)) { + $this->amount_interest = trim($this->amount_interest); + } + if (isset($this->fk_typepayment)) { + $this->fk_typepayment = (int) $this->fk_typepayment; + } + if (isset($this->num_payment)) { + $this->num_payment = (int) $this->num_payment; + } + if (isset($this->note_private)) { + $this->note = trim($this->note_private); + } + if (isset($this->note_public)) { + $this->note = trim($this->note_public); + } + if (isset($this->fk_bank)) { + $this->fk_bank = (int) $this->fk_bank; + } + if (isset($this->fk_user_creat)) { + $this->fk_user_creat = (int) $this->fk_user_creat; + } + if (isset($this->fk_user_modif)) { + $this->fk_user_modif = (int) $this->fk_user_modif; + } // Check parameters @@ -314,13 +354,13 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -347,35 +387,35 @@ class PaymentLoan extends CommonObject $this->db->begin(); - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; $sql .= " WHERE type='payment_loan' AND url_id=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan"; $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Set loan unpaid if loan has no other payment - if (!$error) - { + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $loan = new Loan($this->db); $loan->fetch($this->fk_loan); $sum_payment = $loan->getSumPayment(); - if ($sum_payment == 0) - { + if ($sum_payment == 0) { dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); if ($loan->setUnpaid($user) < 1) { $error++; @@ -401,10 +441,8 @@ class PaymentLoan extends CommonObject //} // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -461,15 +499,16 @@ class PaymentLoan extends CommonObject $error = 0; $this->db->begin(); - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); $total = $this->amount_capital; - if ($mode == 'payment_loan') $total = -$total; + if ($mode == 'payment_loan') { + $total = -$total; + } // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -486,23 +525,21 @@ class PaymentLoan extends CommonObject // Update fk_bank into llx_paiement. // We know the payment who generated the account write - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } // Add link 'payment_loan' in bank_url between payment and bank transaction $url = ''; - if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; - if ($url) - { + if ($mode == 'payment_loan') { + $url = DOL_URL_ROOT.'/loan/payment/card.php?id='; + } + if ($url) { $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode); - if ($result <= 0) - { + if ($result <= 0) { $error++; dol_print_error($this->db); } @@ -510,10 +547,11 @@ class PaymentLoan extends CommonObject // Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - if ($mode == 'payment_loan') - { + if ($mode == 'payment_loan') { $result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan'); - if ($result <= 0) dol_print_error($this->db); + if ($result <= 0) { + dol_print_error($this->db); + } } } else { $this->error = $acc->error; @@ -523,28 +561,23 @@ class PaymentLoan extends CommonObject // Set loan payment started if no set - if (!$error) - { + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; $loan = new Loan($this->db); $loan->fetch($fk_loan); - if ($loan->paid == $loan::STATUS_UNPAID) - { + if ($loan->paid == $loan::STATUS_UNPAID) { dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); - if ($loan->setStarted($user) < 1) - { + if ($loan->setStarted($user) < 1) { $error++; dol_print_error($this->db); } } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; - } - else { + } else { $this->db->rollback(); return -1; } @@ -565,8 +598,7 @@ class PaymentLoan extends CommonObject dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->fk_bank = $id_bank; return 1; } else { @@ -589,27 +621,39 @@ class PaymentLoan extends CommonObject { global $langs, $conf; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; $label = ''.$langs->trans("Loan").''; if (!empty($this->id)) { $label .= '
'.$langs->trans('Ref').': '.$this->id; } - if ($moretitle) $label .= ' - '.$moretitle; + if ($moretitle) { + $label .= ' - '.$moretitle; + } $url = DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id; $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; return $result; diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index a7811dfa04a..545d2ddfabf 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -40,7 +40,9 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'loan', $id, '', ''); // Get parameters @@ -54,11 +56,17 @@ if (empty($page) || $page == -1) { $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "name"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "name"; +} $object = new Loan($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart = 'loan'; @@ -81,8 +89,7 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Documents"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); -if ($object->id) -{ +if ($object->id) { $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); @@ -138,8 +145,7 @@ if ($object->id) // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $totalsize = 0; - foreach ($filearray as $key => $file) - { + foreach ($filearray as $key => $file) { $totalsize += $file['size']; } diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 0d9306aa71f..7ecc41fe4d6 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -38,7 +38,9 @@ $action = GETPOST('action', 'aZ09'); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'loan', $id, '', ''); diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 744a6929fc8..9040d140149 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -32,14 +32,18 @@ $langs->loadLangs(array("loan", "compta", "banks", "bills")); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'loan', '', '', ''); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -48,8 +52,12 @@ $pagenext = $page + 1; $loan_static = new Loan($db); $extrafields = new ExtraFields($db); -if (!$sortfield) $sortfield = "l.rowid"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "l.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); @@ -63,18 +71,22 @@ $optioncss = GETPOST('optioncss', 'alpha'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_ref = ""; $search_label = ""; $search_amount = ""; @@ -97,35 +109,39 @@ $sql .= " SUM(pl.amount_capital) as alreadypaid"; $sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql .= " ON l.rowid = pl.fk_loan"; $sql .= " WHERE l.entity = ".$conf->entity; -if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); -if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); -if ($search_label) $sql .= natural_search("l.label", $search_label); +if ($search_amount) { + $sql .= natural_search("l.capital", $search_amount, 1); +} +if ($search_ref) { + $sql .= " AND l.rowid = ".$db->escape($search_ref); +} +if ($search_label) { + $sql .= natural_search("l.label", $search_label); +} $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -138,24 +154,39 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit llxHeader('', $title, $help_url); -if ($resql) -{ +if ($resql) { $i = 0; $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); - if ($search_label) $param .= "&search_label=".urlencode($search_label); - if ($search_amount) $param .= "&search_amount=".urlencode($search_amount); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($search_ref) { + $param .= "&search_ref=".urlencode($search_ref); + } + if ($search_label) { + $param .= "&search_label=".urlencode($search_label); + } + if ($search_amount) { + $param .= "&search_amount=".urlencode($search_amount); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } $url = DOL_URL_ROOT.'/loan/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } $newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write); print ''."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -201,10 +232,11 @@ if ($resql) // -------------------------------------------------------------------- $i = 0; $totalarray = array(); - while ($i < ($limit ? min($num, $limit) : $num)) - { + while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $loan_static->id = $obj->rowid; $loan_static->ref = $obj->rowid; @@ -240,8 +272,7 @@ if ($resql) } // If no record found - if ($num == 0) - { + if ($num == 0) { $colspan = 7; //foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
'; diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 91f32679699..f7930b64c9a 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -44,7 +44,9 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'loan', $id, '&loan'); $object = new Loan($db); -if ($id > 0) $object->fetch($id); +if ($id > 0) { + $object->fetch($id); +} $permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php @@ -66,11 +68,10 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Notes"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); -if ($id > 0) -{ +if ($id > 0) { /* - * Affichage onglets - */ + * Affichage onglets + */ $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index ac76dbf9053..cf4466bb0da 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -24,7 +24,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; -if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (!empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("bills", "banks", "companies", "loan")); @@ -33,15 +35,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "loan")); $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); $payment = new PaymentLoan($db); -if ($id > 0) -{ +if ($id > 0) { $result = $payment->fetch($id); - if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); + if (!$result) { + dol_print_error($db, 'Failed to get payment id '.$id); + } } @@ -50,8 +55,7 @@ if ($id > 0) */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank; @@ -60,8 +64,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del $fk_loan = $payment->fk_loan; $result = $payment->delete($user); - if ($result > 0) - { + if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan); exit; @@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), -1, 'p /* * Confirm deletion of the payment */ -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } @@ -127,10 +129,8 @@ print ''; // Bank account -if (!empty($conf->banque->enabled)) -{ - if ($payment->bank_account) - { +if (!empty($conf->banque->enabled)) { + if ($payment->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($payment->bank_line); @@ -161,8 +161,7 @@ $sql .= ' AND pl.rowid = '.$payment->id; dol_syslog("loan/payment/card.php", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -176,10 +175,8 @@ if ($resql) print ''; print "\n"; - if ($num > 0) - { - while ($i < $num) - { + if ($num > 0) { + while ($i < $num) { $objp = $db->fetch_object($resql); print ''; @@ -199,8 +196,7 @@ if ($resql) print ''; print "\n"; - if ($objp->paid == 1) // If at least one invoice is paid, disable delete - { + if ($objp->paid == 1) { // If at least one invoice is paid, disable delete $disable_delete = 1; } $total = $total + $objp->amount_capital; @@ -224,10 +220,8 @@ print ''; print '
'; -if (empty($action) && !empty($user->rights->loan->delete)) -{ - if (!$disable_delete) - { +if (empty($action) && !empty($user->rights->loan->delete)) { + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 0c0574c15b4..eec24d9b3e2 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -39,10 +39,14 @@ $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'in // Security check $socid = 0; -if ($user->socid > 0) +if ($user->socid > 0) { $socid = $user->socid; -elseif (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); -if (empty($user->rights->loan->write)) accessforbidden(); +} elseif (GETPOSTISSET('socid')) { + $socid = GETPOST('socid', 'int'); +} +if (empty($user->rights->loan->write)) { + accessforbidden(); +} $loan = new Loan($db); $loan->fetch($chid); @@ -51,35 +55,31 @@ $echance = 0; $ls = new LoanSchedule($db); // grab all loanschedule $res = $ls->fetchAll($chid); -if ($res > 0) -{ - foreach ($ls->lines as $l) - { +if ($res > 0) { + foreach ($ls->lines as $l) { $echance++; // Count term pos // last unpaid term - if (empty($l->fk_bank)) - { + if (empty($l->fk_bank)) { $line_id = $l->id; break; - } - // If line_id provided, only count temp pos - elseif ($line_id == $l->id) - { + } elseif ($line_id == $l->id) { + // If line_id provided, only count temp pos break; } } } // Set current line with last unpaid line (only if shedule is used) -if (!empty($line_id)) -{ +if (!empty($line_id)) { $line = new LoanSchedule($db); $res = $line->fetch($line_id); if ($res > 0) { $amount_capital = price($line->amount_capital); $amount_insurance = price($line->amount_insurance); $amount_interest = price($line->amount_interest); - if (empty($datepaid)) $ts_temppaid = $line->datep; + if (empty($datepaid)) { + $ts_temppaid = $line->datep; + } } } @@ -88,66 +88,59 @@ if (!empty($line_id)) * Actions */ -if ($action == 'add_payment') -{ +if ($action == 'add_payment') { $error = 0; - if ($cancel) - { + if ($cancel) { $loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid; header("Location: ".$loc); exit; } - if (!GETPOST('paymenttype', 'int') > 0) - { + if (!GETPOST('paymenttype', 'int') > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } - if ($datepaid == '') - { + if ($datepaid == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) - { + if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $paymentid = 0; $pay_amount_capital = price2num(GETPOST('amount_capital')); $pay_amount_insurance = price2num(GETPOST('amount_insurance')); // User can't set interest him self if schedule is set (else value in schedule can be incoherent) - if (!empty($line)) $pay_amount_interest = $line->amount_interest; - else $pay_amount_interest = price2num(GETPOST('amount_interest')); + if (!empty($line)) { + $pay_amount_interest = $line->amount_interest; + } else { + $pay_amount_interest = price2num(GETPOST('amount_interest')); + } $remaindertopay = price2num(GETPOST('remaindertopay')); $amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest; // This term is allready paid - if (!empty($line) && !empty($line->fk_bank)) - { + if (!empty($line) && !empty($line->fk_bank)) { setEventMessages($langs->trans('TermPaidAllreadyPaid'), null, 'errors'); $error++; } - if (empty($remaindertopay)) - { + if (empty($remaindertopay)) { setEventMessages('Empty sumpaid', null, 'errors'); $error++; } - if ($amount == 0) - { + if ($amount == 0) { setEventMessages($langs->trans('ErrorNoPaymentDefined'), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); // Create a line of payments @@ -164,38 +157,30 @@ if ($action == 'add_payment') $payment->note_private = GETPOST('note_private', 'restricthtml'); $payment->note_public = GETPOST('note_public', 'restricthtml'); - if (!$error) - { + if (!$error) { $paymentid = $payment->create($user); - if ($paymentid < 0) - { + if ($paymentid < 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', $payment->fk_bank, '', ''); - if (!$result > 0) - { + if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } } // Update loan schedule with payment value - if (!$error && !empty($line)) - { + if (!$error && !empty($line)) { // If payment values are modified, recalculate schedule - if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) - { + if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) { $arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm); - foreach ($arr_term as $k=>$v) - { + foreach ($arr_term as $k => $v) { // Update fk_bank for current line - if ($k == $echance) - { + if ($k == $echance) { $ls->lines[$k - 1]->fk_bank = $payment->fk_bank; $ls->lines[$k - 1]->fk_payment_loan = $payment->id; } @@ -204,29 +189,25 @@ if ($action == 'add_payment') $ls->lines[$k - 1]->tms = dol_now(); $ls->lines[$k - 1]->fk_user_modif = $user->id; $result = $ls->lines[$k - 1]->update($user, 0); - if ($result < 1) - { + if ($result < 1) { setEventMessages(null, $ls->errors, 'errors'); $error++; break; } } - } - else // Only add fk_bank bank to schedule line (mark as paid) + } else // Only add fk_bank bank to schedule line (mark as paid) { $line->fk_bank = $payment->fk_bank; $line->fk_payment_loan = $payment->id; $result = $line->update($user, 0); - if ($result < 1) - { + if ($result < 1) { setEventMessages(null, $line->errors, 'errors'); $error++; } } } - if (!$error) - { + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid; header('Location: '.$loc); @@ -251,8 +232,7 @@ $form = new Form($db); // Form to create loan's payment -if ($action == 'create') -{ +if ($action == 'create') { $total = $loan->capital; print load_fiche_titre($langs->trans("DoPayment")); @@ -261,8 +241,7 @@ if ($action == 'create') $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan"; $sql .= " WHERE fk_loan = ".$chid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); @@ -282,10 +261,10 @@ if ($action == 'create') print '
'.$langs->trans("LoanCapital").''; print '
'.$langs->trans("Insurance").''; print '
'.$langs->trans("DateStart").""; - if ($action == 'edit') - { + if ($action == 'edit') { print $form->selectDate($object->datestart, 'start', 0, 0, 0, 'update', 1, 0); } else { print dol_print_date($object->datestart, "day"); @@ -499,8 +501,7 @@ if ($id > 0) // Date end print '
'.$langs->trans("DateEnd").""; - if ($action == 'edit') - { + if ($action == 'edit') { print $form->selectDate($object->dateend, 'end', 0, 0, 0, 'update', 1, 0); } else { print dol_print_date($object->dateend, "day"); @@ -510,8 +511,7 @@ if ($id > 0) // Nbterms print '
'.$langs->trans("Nbterms").''; - if ($action == 'edit') - { + if ($action == 'edit') { print ''; } else { print $object->nbterm; @@ -521,8 +521,7 @@ if ($id > 0) // Rate print '
'.$langs->trans("Rate").''; - if ($action == 'edit') - { + if ($action == 'edit') { print '%'; } else { print price($object->rate).'%'; @@ -531,14 +530,12 @@ if ($id > 0) // Accountancy account capital print '
'; print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1); } else { print ''; @@ -549,8 +546,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_capital, 1); @@ -565,14 +561,12 @@ if ($id > 0) // Accountancy account insurance print '
'; print $langs->trans("LoanAccountancyInsuranceCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1); } else { print ''; @@ -583,8 +577,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInsuranceCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_insurance, 1); @@ -599,14 +592,12 @@ if ($id > 0) // Accountancy account interest print '
'; print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1); } else { print ''; @@ -617,8 +608,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_interest, 1); @@ -653,8 +643,7 @@ if ($id > 0) //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; $total_insurance = 0; @@ -672,8 +661,7 @@ if ($id > 0) print ''.$langs->trans("LoanCapital").'
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("NoRecordFound").'
'.$langs->trans('NotePrivate').''.nl2br($payment->note_p print '
'.$langs->trans('NotePublic').''.nl2br($payment->note_public).'
'.$langs->trans('PayedByThisPayment').'
'.price($amount_payed).'
'; print ''; - if ($echance > 0) - { - print ''."\n"; - } + if ($echance > 0) + { + print ''."\n"; + } print '\n"; print '\n"; print ''; @@ -300,108 +279,106 @@ if ($action == 'create') print '
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Term").''.$echance.'
'.$langs->trans("Term").''.$echance.'
'.$langs->trans("DateStart").''.dol_print_date($loan->datestart, 'day')."
'.$langs->trans("Label").''.$loan->label."
'.$langs->trans("Amount").''.price($loan->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'; print '"; - print ''; + if (empty($datepaid)) { + if (empty($ts_temppaid)) { + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now(); + } else { + $datepayment = $ts_temppaid; + } + } else { + $datepayment = $datepaid; + } + print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); + print ""; + print ''; - print '\n"; - print ''; + print '\n"; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; // Number - print ''; - print ''."\n"; - print ""; + print ''; + print ''."\n"; + print ""; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print '
'.$langs->trans("Date").''; - if (empty($datepaid)) - if (empty($ts_temppaid)) $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now(); - else $datepayment = $ts_temppaid; - else $datepayment = $datepaid; - print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); - print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype"); - print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype"); + print "
'.$langs->trans('AccountToDebit').''; - $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list - print '
'.$langs->trans('AccountToDebit').''; + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list + print '
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans("NotePrivate").'
'.$langs->trans("NotePrivate").'
'.$langs->trans("NotePublic").'
'.$langs->trans("NotePublic").'
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'.$langs->trans("DateDue").''.$langs->trans("LoanCapital").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - print ''; + print ''; - if ($loan->datestart > 0) - { + if ($loan->datestart > 0) { print ''; } else { print ''; } - print '"; + print '"; - print '"; + print '"; - print '"; + print '"; - print '"; + print ""; - print "\n"; + print "\n"; - print '
'.$langs->trans("DateDue").''.$langs->trans("LoanCapital").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.dol_print_date($loan->datestart, 'day').'!!!'.price($loan->capital)."'.price($loan->capital)."'.price($sumpaid)."'.price($sumpaid)."'.price($loan->capital - $sumpaid)."'.price($loan->capital - $sumpaid)."'; - if ($sumpaid < $loan->capital) - { + print ''; + if ($sumpaid < $loan->capital) { print $langs->trans("LoanCapital").': '; - } - else { + } else { print '-'; } - print '
'; - if ($sumpaid < $loan->capital) - { + print '
'; + if ($sumpaid < $loan->capital) { print $langs->trans("Insurance").': '; - } - else { + } else { print '-'; } - print '
'; - if ($sumpaid < $loan->capital) - { + print '
'; + if ($sumpaid < $loan->capital) { print $langs->trans("Interest").': '; - } - else { + } else { print '-'; } - print "
'; + print ''; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print "
\n"; + print "\n"; } llxFooter(); diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index b9e6783ceca..2969d6958b5 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -35,9 +35,15 @@ $action = GETPOST('action', 'aZ09'); // Security check $socid = 0; -if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid = $user->socid; -if (empty($user->rights->loan->calc)) accessforbidden(); +if (GETPOSTISSET('socid')) { + $socid = GETPOST('socid', 'int'); +} +if ($user->socid) { + $socid = $user->socid; +} +if (empty($user->rights->loan->calc)) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "loan")); @@ -120,7 +126,9 @@ if ($action == 'updateecheancier' && empty($pay_without_schedule)) { $echeances->lines[$i - 1] = $new_echeance; $i++; } - if ($result > 0) $db->commit(); + if ($result > 0) { + $db->commit(); + } } /* @@ -141,24 +149,23 @@ $morehtmlref = '
'; $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); $morehtmlref .= '
'.$langs->trans('Project').' : '; - if ($user->rights->loan->write) - { - if ($action != 'classify') + if ($user->rights->loan->write) { + if ($action != 'classify') { //$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } } else { if (!empty($object->fk_project)) { @@ -212,14 +219,14 @@ $(document).ready(function() { '.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'
'."\n"; +} print '
'; print ''; print ''; -if (count($echeances->lines) > 0) -{ +if (count($echeances->lines) > 0) { print ''; } else { print ''; @@ -229,7 +236,9 @@ print '
'; print ''; print ''; $colspan = 6; -if (count($echeances->lines) > 0) $colspan++; +if (count($echeances->lines) > 0) { + $colspan++; +} print ''; @@ -245,18 +254,18 @@ print ''; -if (count($echeances->lines) > 0) print ''; +if (count($echeances->lines) > 0) { + print ''; +} print ''."\n"; -if ($object->nbterm > 0 && count($echeances->lines) == 0) -{ +if ($object->nbterm > 0 && count($echeances->lines) == 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; $insurance = price2num($insurance, 'MT'); $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); - while ($i < $object->nbterm + 1) - { + while ($i < $object->nbterm + 1) { $mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); $int = ($capital * ($object->rate / 12)) / 100; $int = price2num($int, 'MT'); @@ -273,8 +282,7 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) $i++; $capital = $cap_rest; } -} elseif (count($echeances->lines) > 0) -{ +} elseif (count($echeances->lines) > 0) { $i = 1; $capital = $object->capital; $insurance = $object->insurance_amount / $object->nbterm; @@ -300,14 +308,12 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0) print ''; print ''; print ''; print ''; @@ -153,12 +150,10 @@ print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '\n"; $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); print ''; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 1693462b749..05d5aa1ca5c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -36,7 +36,9 @@ $socid = GETPOST('socid', 'int'); $TSelectedProducts = GETPOST('products', 'array'); $TSelectedCats = GETPOST('categories', 'array'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'margins'); @@ -48,19 +50,27 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "s.nom"; // Set here default search field -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "s.nom"; // Set here default search field +} +if (!$sortorder) { + $sortorder = "ASC"; +} $startdate = $enddate = ''; -if (!empty($_POST['startdatemonth'])) - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); -if (!empty($_POST['enddatemonth'])) - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (!empty($_POST['startdatemonth'])) { + $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +} +if (!empty($_POST['enddatemonth'])) { + $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); @@ -98,16 +108,19 @@ if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - if ($soc->client) - { + if ($soc->client) { print ''; print ''; $client = true; - if (!$sortorder) $sortorder = "DESC"; - if (!$sortfield) $sortfield = "f.datef"; + if (!$sortorder) { + $sortorder = "DESC"; + } + if (!$sortfield) { + $sortfield = "f.datef"; + } } } else { print ''; @@ -118,11 +131,11 @@ if ($socid > 0) { $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) -{ - if ($client) - { +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + if ($client) { $sortfield = "f.datef"; $sortorder = "DESC"; } else { @@ -202,7 +215,9 @@ $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABAND $sql = "SELECT"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; -if ($client) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +if ($client) { + $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +} $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) $sql .= " sum(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1 * (d.situation_percent / 100)', 'd.qty * d.buy_price_ht * (d.situation_percent / 100)').") as buying_price,"; @@ -214,10 +229,16 @@ if (!empty($TSelectedCats)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product'; } -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} $sql .= " WHERE f.fk_soc = s.rowid"; -if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid > 0) { + $sql .= ' AND s.rowid = '.$socid; +} +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +} $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= ' AND s.entity IN ('.getEntity('societe').')'; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; @@ -229,32 +250,38 @@ if (!empty($TSelectedProducts)) { if (!empty($TSelectedCats)) { $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; } -if (!empty($startdate)) -$sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) -$sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) -$sql .= " AND d.buy_price_ht <> 0"; -if ($client) $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; -else $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; +} +if ($client) { + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; +} else { + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; +} $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin::customerMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); - print '
'; + print '
'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -264,33 +291,34 @@ if ($result) print ''; if (!empty($client)) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$socid, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$socid, 'align="center"', $sortfield, $sortorder); - } else print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=".$socid, '', $sortfield, $sortorder); + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$socid, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$socid, 'align="center"', $sortfield, $sortorder); + } else { + print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=".$socid, '', $sortfield, $sortorder); + } print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder); + } print "\n"; $cumul_achat = 0; $cumul_vente = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $pa = $objp->buying_price; $pv = $objp->selling_price; $marge = $objp->marge; - if ($marge < 0) - { + if ($marge < 0) { $marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : ''; $markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : ''; } else { @@ -307,20 +335,22 @@ if ($result) print ''; print ''; - } else { + } else { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - print ''; - } + print ''; + } print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print "\n"; $i++; @@ -344,17 +374,21 @@ if ($result) //} print ''; - if ($client) + if ($client) { print '"; + } else { + print '"; print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; print '
'; print $langs->trans("FinancialCommitment"); print ''.$langs->trans("CapitalRemain"); print '
('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; print ''; print '
'.$langs->trans('DoPayment').''.$langs->trans('DoPayment').'
'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).''; - if (!empty($line->fk_bank)) - { + if (!empty($line->fk_bank)) { print $langs->trans('Paid'); - if (!empty($line->fk_payment_loan)) + if (!empty($line->fk_payment_loan)) { print ' ('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')'; - } - elseif (!$printed) - { + } + } elseif (!$printed) { print ''.$langs->trans('DoPayment').''; $printed = true; } @@ -323,8 +329,11 @@ print ''; print '
'; -if (count($echeances->lines) == 0) $label = $langs->trans("Create"); -else $label = $langs->trans("Save"); +if (count($echeances->lines) == 0) { + $label = $langs->trans("Create"); +} else { + $label = $langs->trans("Save"); +} print '
'; print ''; diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index a0a636dd136..d08f6f65094 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -77,8 +77,7 @@ class MailmanSpip */ public function isSpipEnabled() { - if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) - { + if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) { return true; } @@ -92,10 +91,8 @@ class MailmanSpip */ public function checkSpipConfig() { - if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) - { - if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') - { + if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) { + if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') { return true; } } @@ -112,8 +109,7 @@ class MailmanSpip { $resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT); - if ($resource->ok) - { + if ($resource->ok) { return $resource; } @@ -165,8 +161,7 @@ class MailmanSpip dol_syslog('result curl_exec='.$result); //An error was found, we store it in $this->error for later - if ($result === false || curl_errno($ch) > 0) - { + if ($result === false || curl_errno($ch) > 0) { $this->error = curl_errno($ch).' '.curl_error($ch); dol_syslog('Error using curl '.$this->error, LOG_ERR); } @@ -188,14 +183,11 @@ class MailmanSpip // phpcs:enable dol_syslog(get_class($this)."::add_to_spip"); - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $mdpass = dol_hash($object->pass); $htpass = crypt($object->pass, makesalt()); @@ -205,13 +197,20 @@ class MailmanSpip $mydb->close(); - if ($result) - { + if ($result) { return 1; - } else $this->error = $mydb->lasterror(); - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = $mydb->lasterror(); + } + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return 0; } @@ -228,27 +227,31 @@ class MailmanSpip // phpcs:enable dol_syslog(get_class($this)."::del_to_spip"); - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { $query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'"; $result = $mydb->query($query); $mydb->close(); - if ($result) - { + if ($result) { return 1; - } else $this->error = $mydb->lasterror(); - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = $mydb->lasterror(); + } + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return 0; } @@ -263,22 +266,17 @@ class MailmanSpip public function is_in_spip($object) { // phpcs:enable - if ($this->isSpipEnabled()) - { - if ($this->checkSpipConfig()) - { + if ($this->isSpipEnabled()) { + if ($this->checkSpipConfig()) { $mydb = $this->connectSpip(); - if ($mydb) - { + if ($mydb) { $query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'"; $result = $mydb->query($query); - if ($result) - { - if ($mydb->num_rows($result)) - { + if ($result) { + if ($mydb->num_rows($result)) { // nous avons au moins une reponse $mydb->close($result); return 1; @@ -291,9 +289,15 @@ class MailmanSpip $this->error = $mydb->lasterror(); $mydb->close(); } - } else $this->error = 'Failed to connect to SPIP'; - } else $this->error = 'BadSPIPConfiguration'; - } else $this->error = 'SPIPNotEnabled'; + } else { + $this->error = 'Failed to connect to SPIP'; + } + } else { + $this->error = 'BadSPIPConfiguration'; + } + } else { + $this->error = 'SPIPNotEnabled'; + } return -1; } @@ -316,36 +320,32 @@ class MailmanSpip $this->mladded_ok = array(); $this->mladded_ko = array(); - if (!function_exists("curl_init")) - { + if (!function_exists("curl_init")) { $langs->load("errors"); $this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); return -1; } - if ($conf->adherent->enabled) // Synchro for members - { - if (!empty($conf->global->ADHERENT_MAILMAN_URL)) - { - if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); - else $lists = explode(',', $listes); + if ($conf->adherent->enabled) { // Synchro for members + if (!empty($conf->global->ADHERENT_MAILMAN_URL)) { + if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) { + $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); + } else { + $lists = explode(',', $listes); + } $categstatic = new Categorie($this->db); - foreach ($lists as $list) - { + foreach ($lists as $list) { // Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2") $tmp = explode(':', $list); - if (!empty($tmp[2])) - { + if (!empty($tmp[2])) { $list = $tmp[2]; - if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label - { + if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG); continue; } - if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category - { + if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG); continue; } @@ -354,11 +354,12 @@ class MailmanSpip //We call Mailman to subscribe the user $result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_URL, $list); - if ($result === false) - { + if ($result === false) { $this->mladded_ko[$list] = $object->email; return -2; - } else $this->mladded_ok[$list] = $object->email; + } else { + $this->mladded_ok[$list] = $object->email; + } } return count($lists); } else { @@ -387,36 +388,32 @@ class MailmanSpip $this->mlremoved_ok = array(); $this->mlremoved_ko = array(); - if (!function_exists("curl_init")) - { + if (!function_exists("curl_init")) { $langs->load("errors"); $this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init"); return -1; } - if ($conf->adherent->enabled) // Synchro for members - { - if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) - { - if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); - else $lists = explode(',', $listes); + if ($conf->adherent->enabled) { // Synchro for members + if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) { + if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) { + $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS); + } else { + $lists = explode(',', $listes); + } $categstatic = new Categorie($this->db); - foreach ($lists as $list) - { + foreach ($lists as $list) { // Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2") $tmp = explode(':', $list); - if (!empty($tmp[2])) - { + if (!empty($tmp[2])) { $list = $tmp[2]; - if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label - { + if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG); continue; } - if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category - { + if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG); continue; } @@ -425,11 +422,12 @@ class MailmanSpip //We call Mailman to unsubscribe the user $result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list); - if ($result === false) - { + if ($result === false) { $this->mlremoved_ko[$list] = $object->email; return -2; - } else $this->mlremoved_ok[$list] = $object->email; + } else { + $this->mlremoved_ok[$list] = $object->email; + } } return count($lists); } else { diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index d9c470b7acd..c041700fa18 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; $langs->loadLangs(array("admin", "bills", "margins", "stocks")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -40,11 +42,9 @@ $action = GETPOST('action', 'aZ09'); * Action */ -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -52,11 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) } } -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -64,30 +62,24 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) } } -if ($action == 'remises') -{ - if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'remises') { + if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); } } -if ($action == 'typemarges') -{ - if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'typemarges') { + if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); } } -if ($action == 'contact') -{ - if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) - { +if ($action == 'contact') { + if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } else { dol_print_error($db); @@ -126,18 +118,23 @@ print '
'.$langs->trans("MARGIN_TYPE").''; print ' global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') { print 'checked '; +} print '/> '; print $langs->trans('MargeType1'); print '
'; print ' global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') print 'checked '; +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') { + print 'checked '; +} print '/> '; print $langs->trans('MargeType2'); print '
'; print ' global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') print 'checked '; +if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') { + print 'checked '; +} print '/> '; print $langs->trans('MargeType3'); print '
'.$langs->trans("DisplayMarginRates").''; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARGIN_RATES'); } else { - if (empty($conf->global->DISPLAY_MARGIN_RATES)) - { + if (empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -172,12 +167,10 @@ print '
'.$langs->trans("DisplayMarkRates").''; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('DISPLAY_MARK_RATES'); } else { - if (empty($conf->global->DISPLAY_MARK_RATES)) - { + if (empty($conf->global->DISPLAY_MARK_RATES)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -191,12 +184,10 @@ print '
'.$langs->trans("ForceBuyingPriceIfNull").''; -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('ForceBuyingPriceIfNull'); } else { - if (empty($conf->global->ForceBuyingPriceIfNull)) - { + if (empty($conf->global->ForceBuyingPriceIfNull)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index d97d992b99d..717e2d02c1b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -39,16 +39,21 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) -{ - if ($agentid > 0) +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + if ($agentid > 0) { $sortfield = "s.nom"; - else $sortfield = "u.lastname"; + } else { + $sortfield = "u.lastname"; + } } $startdate = $enddate = ''; @@ -60,10 +65,12 @@ $enddateday = GETPOST('enddateday', 'int'); $enddatemonth = GETPOST('enddatemonth', 'int'); $enddateyear = GETPOST('enddateyear', 'int'); -if (!empty($startdatemonth)) +if (!empty($startdatemonth)) { $startdate = dol_mktime(0, 0, 0, $startdatemonth, $startdateday, $startdateyear); -if (!empty($enddatemonth)) +} +if (!empty($enddatemonth)) { $enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear); +} // Security check if ($user->rights->margins->read->all) { @@ -154,23 +161,31 @@ $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND sc.fk_soc = f.fk_soc"; $sql .= " AND (d.product_type = 0 OR d.product_type = 1)"; -if (!empty($conf->global->AGENT_CONTACT_TYPE)) +if (!empty($conf->global->AGENT_CONTACT_TYPE)) { $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; -else $sql .= " AND sc.fk_user = u.rowid"; +} else { + $sql .= " AND sc.fk_user = u.rowid"; +} $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= ' AND s.entity IN ('.getEntity('societe').')'; $sql .= " AND d.fk_facture = f.rowid"; if ($agentid > 0) { - if (!empty($conf->global->AGENT_CONTACT_TYPE)) - $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; - else $sql .= " AND sc.fk_user = ".$agentid; + if (!empty($conf->global->AGENT_CONTACT_TYPE)) { + $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; + } else { + $sql .= " AND sc.fk_user = ".$agentid; + } +} +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; } -if (!empty($startdate)) - $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) - $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; +} //if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; //else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname"; $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; @@ -183,28 +198,42 @@ print '
'; print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'
'; $param = ''; -if (!empty($agentid)) $param .= "&agentid=".urlencode($agentid); -if (!empty($startdateday)) $param .= "&startdateday=".urlencode($startdateday); -if (!empty($startdatemonth)) $param .= "&startdatemonth=".urlencode($startdatemonth); -if (!empty($startdateyear)) $param .= "&startdateyear=".urlencode($startdateyear); -if (!empty($enddateday)) $param .= "&enddateday=".urlencode($enddateday); -if (!empty($enddatemonth)) $param .= "&enddatemonth=".urlencode($enddatemonth); -if (!empty($enddateyear)) $param .= "&enddateyear=".urlencode($enddateyear); +if (!empty($agentid)) { + $param .= "&agentid=".urlencode($agentid); +} +if (!empty($startdateday)) { + $param .= "&startdateday=".urlencode($startdateday); +} +if (!empty($startdatemonth)) { + $param .= "&startdatemonth=".urlencode($startdatemonth); +} +if (!empty($startdateyear)) { + $param .= "&startdateyear=".urlencode($startdateyear); +} +if (!empty($enddateday)) { + $param .= "&enddateday=".urlencode($enddateday); +} +if (!empty($enddatemonth)) { + $param .= "&enddatemonth=".urlencode($enddatemonth); +} +if (!empty($enddateyear)) { + $param .= "&enddateyear=".urlencode($enddateyear); +} dol_syslog('margin::agentMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); print '
'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -213,21 +242,24 @@ if ($result) print ''."\n"; print ''; - if ($agentid > 0) + if ($agentid > 0) { print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + } else { + print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + } print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + } print "\n"; - if ($num > 0) - { + if ($num > 0) { $group_list = array(); while ($objp = $db->fetch_object($result)) { if ($agentid > 0) { @@ -295,10 +327,12 @@ if ($result) print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print "\n"; $i++; @@ -319,10 +353,12 @@ if ($result) print ''; print ''; print ''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''; + } print ''; print '
'.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'
'.price(price2num($cumul_vente, 'MT')).''.price(price2num($cumul_achat, 'MT')).''.price(price2num($totalMargin, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'
'; diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5d019b2693a..f61d8d02e55 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -44,12 +44,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = 'f.ref'; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = 'f.ref'; +} $startdate = $enddate = ''; @@ -73,15 +79,20 @@ if (GETPOST("button_search_x") || GETPOST("button_search")) { * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -108,23 +119,22 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_ref = ''; $search_array_options = array(); } // Mass actions /* - $objectclass='Product'; - if ((string) $type == '1') { $objectlabel='Services'; } - if ((string) $type == '0') { $objectlabel='Products'; } + $objectclass='Product'; + if ((string) $type == '1') { $objectlabel='Services'; } + if ((string) $type == '0') { $objectlabel='Products'; } - $permissiontoread = $user->rights->produit->lire; - $permissiontodelete = $user->rights->produit->supprimer; - $uploaddir = $conf->product->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - */ + $permissiontoread = $user->rights->produit->lire; + $permissiontodelete = $user->rights->produit->supprimer; + $uploaddir = $conf->product->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ } @@ -146,12 +156,24 @@ llxHeader('', $title); // print load_fiche_titre($text); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); -if (!empty($startdate)) $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int'); -if (!empty($enddate)) $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int'); -if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.$contextpage; +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.$limit; +} +if ($search_ref != '') { + $param .= '&search_ref='.urlencode($search_ref); +} +if (!empty($startdate)) { + $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int'); +} +if (!empty($enddate)) { + $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') { + $param .= '&optioncss='.$optioncss; +} // Show tabs $head = marges_prepare_head($user); @@ -194,9 +216,15 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowi $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql .= " WHERE f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= " AND f.entity IN (".getEntity('invoice').") "; -if (!empty($startdate)) $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; -if ($search_ref) $sql .= natural_search('f.ref', $search_ref); +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} +if ($search_ref) { + $sql .= natural_search('f.ref', $search_ref); +} $sql .= " AND d.buy_price_ht IS NOT NULL"; $sql .= $db->order($sortfield, $sortorder); @@ -205,8 +233,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -221,10 +248,11 @@ if ($result) { print '
'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -260,8 +288,7 @@ if ($result) { print "
'.$langs->trans('ThirdPartyName').''; print img_picto('', 'company').$form->select_company($socid, 'socid', '(client=1 OR client=3)', 1, 0, 0); print '
'.$langs->trans('ThirdPartyName').'
'; print dol_print_date($db->jdate($objp->datef), 'day').''.$companystatic->getNomUrl(1, 'margin').''.$companystatic->getNomUrl(1, 'margin').''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'
'; - else print ''; - print $langs->trans('TotalMargin')."'; + } + print $langs->trans('TotalMargin')."'.price(price2num($cumul_vente, 'MT')).''.price(price2num($cumul_achat, 'MT')).''.price(price2num($totalMargin, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'
'; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 6161ba2b6e4..802541b98ca 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -124,8 +124,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta if ($fk_pa > 0 && empty($paht)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product = new ProductFournisseur($db); - if ($product->fetch_product_fournisseur_price($fk_pa)) - { + if ($product->fetch_product_fournisseur_price($fk_pa)) { $paht_ret = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); } else { $paht_ret = $paht; @@ -141,16 +140,20 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta $pu_ht_remise = price2num($pu_ht_remise, 'MU'); // calcul marge - if ($pu_ht_remise < 0) + if ($pu_ht_remise < 0) { $marge = -1 * (abs($pu_ht_remise) - $paht_ret); - else $marge = $pu_ht_remise - $paht_ret; + } else { + $marge = $pu_ht_remise - $paht_ret; + } // calcul taux marge - if ($paht_ret != 0) + if ($paht_ret != 0) { $marge_tx_ret = (100 * $marge) / $paht_ret; + } // calcul taux marque - if ($pu_ht_remise != 0) + if ($pu_ht_remise != 0) { $marque_tx_ret = (100 * $marge) / $pu_ht_remise; + } return array($paht_ret, $marge_tx_ret, $marque_tx_ret); } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 3bb7eff8e23..0ac47243723 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -41,9 +41,13 @@ $TSelectedCats = GETPOST('categories', 'array'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->margins->liretous)) accessforbidden(); +if (empty($user->rights->margins->liretous)) { + accessforbidden(); +} $mesg = ''; @@ -52,14 +56,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) -{ - if ($id > 0) - { +if (!$sortfield) { + if ($id > 0) { $sortfield = "f.datef"; $sortorder = "DESC"; } else { @@ -70,10 +74,12 @@ if (!$sortfield) $startdate = $enddate = ''; -if (!empty($_POST['startdatemonth'])) - $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); -if (!empty($_POST['enddatemonth'])) - $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +if (!empty($_POST['startdatemonth'])) { + $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']); +} +if (!empty($_POST['enddatemonth'])) { + $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Product($db); @@ -169,8 +175,12 @@ print ''; $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; -if ($id > 0) $sql .= " d.fk_product,"; -if ($id > 0) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +if ($id > 0) { + $sql .= " d.fk_product,"; +} +if ($id > 0) { + $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; +} $sql .= " SUM(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) $sql .= " SUM(d.qty) as product_qty,"; @@ -187,38 +197,45 @@ $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; $sql .= " AND d.fk_facture = f.rowid"; -if ($id > 0) +if ($id > 0) { $sql .= " AND d.fk_product =".$id; +} if (!empty($TSelectedCats)) { $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; } -if (!empty($startdate)) - $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) - $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +if (!empty($startdate)) { + $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; +} +if (!empty($enddate)) { + $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; +} $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { $sql .= " AND d.buy_price_ht <> 0"; -if ($id > 0) $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; -else $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; +} +if ($id > 0) { + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; +} else { + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; +} $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin::productMargins.php', LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); print '
'; print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); - if ($conf->global->MARGIN_TYPE == "1") + if ($conf->global->MARGIN_TYPE == "1") { $labelcostprice = 'BuyingPrice'; - else // value is 'costprice' or 'pmp' + } else { // value is 'costprice' or 'pmp' $labelcostprice = 'CostPrice'; + } $moreforfilter = ''; @@ -228,37 +245,36 @@ if ($result) print ''; if ($id > 0) { - print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&id=".$id, '', $sortfield, $sortorder); - print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$id, '', $sortfield, $sortorder, 'center '); - } else { - print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&id=".$id, '', $sortfield, $sortorder); - } + print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&id=".$id, '', $sortfield, $sortorder); + print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$id, '', $sortfield, $sortorder, 'center '); + } else { + print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&id=".$id, '', $sortfield, $sortorder); + } print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", "&id=".$id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right '); + } print "\n"; $cumul_achat = 0; $cumul_vente = 0; $cumul_qty = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $qty = $objp->product_qty; $pa = $objp->buying_price; $pv = $objp->selling_price; $marge = $objp->marge; - if ($marge < 0) - { + if ($marge < 0) { $marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : ''; $markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : ''; } else { @@ -277,8 +293,7 @@ if ($result) print dol_print_date($db->jdate($objp->datef), 'day').""; } else { print ''; - if ($objp->rowid > 0) - { + if ($objp->rowid > 0) { $product_static->type = $objp->fk_product_type; $product_static->id = $objp->rowid; $product_static->ref = $objp->ref; @@ -296,10 +311,12 @@ if ($result) print ''.price(price2num($pv, 'MT')).''; print ''.price(price2num($pa, 'MT')).''; print ''.price(price2num($marge, 'MT')).''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; + } print "\n"; $i++; @@ -317,18 +334,22 @@ if ($result) $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : ''; print ''; - if ($id > 0) + if ($id > 0) { print ''; - else print ''; + } else { + print ''; + } print $langs->trans('TotalMargin').''; print ''.$cumul_qty.''; print ''.price(price2num($cumul_vente, 'MT')).''; print ''.price(price2num($cumul_achat, 'MT')).''; print ''.price(price2num($totalMargin, 'MT')).''; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; + } print "\n"; print ""; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 5fcec11c93b..031c49e4cd0 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -36,9 +36,13 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->margins->liretous)) accessforbidden(); +if (empty($user->rights->margins->liretous)) { + accessforbidden(); +} $object = new Product($db); @@ -46,12 +50,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} /* @@ -62,20 +72,17 @@ $invoicestatic = new Facture($db); $form = new Form($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $title = $langs->trans('ProductServiceCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) - { + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) - { + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } @@ -85,8 +92,7 @@ if ($id > 0 || !empty($ref)) /* * En mode visu */ - if ($result > 0) - { + if ($result > 0) { $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -133,7 +139,9 @@ if ($id > 0 || !empty($ref)) $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " sc.fk_soc, sc.fk_user,"; + } $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // not always positive in case of Credit note @@ -141,18 +149,28 @@ if ($id > 0 || !empty($ref)) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.fk_statut > 0"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND d.fk_product =".$object->id; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if (!empty($socid)) $sql .= " AND f.fk_soc = $socid"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if (!empty($socid)) { + $sql .= " AND f.fk_soc = $socid"; + } $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; + } $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user"; + } $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -177,10 +195,12 @@ if ($id > 0 || !empty($ref)) print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; @@ -209,10 +229,12 @@ if ($id > 0 || !empty($ref)) print "".price(price2num($objp->buying_price, 'MT'))."\n"; print "".price(price2num($objp->qty, 'MT'))."\n"; print "".price(price2num($objp->marge, 'MT'))."\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + } print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; @@ -225,8 +247,7 @@ if ($id > 0 || !empty($ref)) // affichage totaux marges $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) - { + if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { @@ -239,10 +260,12 @@ if ($id > 0 || !empty($ref)) print ''.price(price2num($cumul_achat, 'MT'))."\n"; print ''.price(price2num($cumul_qty, 'MT'))."\n"; print ''.price(price2num($totalMargin, 'MT'))."\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + } print ' '; print "\n"; print ""; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bfa5ac15811..0103bd03aca 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -30,7 +30,9 @@ $langs->loadLangs(array("companies", "bills", "products", "margins")); // Security check $socid = GETPOST('socid', 'int'); -if (!empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) { + $socid = $user->socid; +} $result = restrictedArea($user, 'societe', '', ''); @@ -38,15 +40,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "f.datef"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "f.datef"; +} $object = new Societe($db); -if ($socid > 0) $object->fetch($socid); +if ($socid > 0) { + $object->fetch($socid); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartymargins', 'globalcard')); @@ -58,7 +68,9 @@ $hookmanager->initHooks(array('thirdpartymargins', 'globalcard')); $parameters = array('id'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} @@ -70,18 +82,19 @@ $invoicestatic = new Facture($db); $form = new Form($db); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Margins"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { + $title = $object->name.' - '.$langs->trans("Files"); +} $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if ($socid > 0) -{ +if ($socid > 0) { $object = new Societe($db); $object->fetch($socid); /* - * Affichage onglets - */ + * Affichage onglets + */ $head = societe_prepare_head($object); @@ -96,27 +109,25 @@ if ($socid > 0) print '
'; print ''; - if ($object->client) - { - print ''; - } + if ($object->client) { + print ''; + } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) - { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; } @@ -163,7 +174,9 @@ if ($socid > 0) $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND f.fk_soc = $socid"; $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + $sql .= " AND d.buy_price_ht <> 0"; + } $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination @@ -171,8 +184,7 @@ if ($socid > 0) dol_syslog('margin:tabs:thirdpartyMargins.php', LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&socid=".$object->id, $sortfield, $sortorder, '', $num, $num, ''); @@ -187,20 +199,20 @@ if ($socid > 0) print_liste_field_titre("SoldAmount", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PurchasedAmount", $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); + } print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&socid=".$_REQUEST["socid"], '', $sortfield, $sortorder, 'right '); print "\n"; $cumul_achat = 0; $cumul_vente = 0; - if ($num > 0) - { - while ($i < $num /*&& $i < $conf->liste_limit*/) - { + if ($num > 0) { + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : ''; @@ -222,10 +234,12 @@ if ($socid > 0) print "\n"; print "\n"; print "\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "\n"; + } print ''; print "\n"; $i++; @@ -237,8 +251,7 @@ if ($socid > 0) // affichage totaux marges $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) - { + if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { @@ -252,10 +265,12 @@ if ($socid > 0) print "\n"; print "\n"; print "\n"; - if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print "\n"; - if (!empty($conf->global->DISPLAY_MARK_RATES)) + } + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print "\n"; + } print ''; print "\n"; } else { diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index c5b41ac9390..e9e3ea752f5 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -26,8 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; global $conf, $langs, $user, $db; $langs->loadLangs(array("admin", "other", "modulebuilder")); -if (!$user->admin || empty($conf->modulebuilder->enabled)) +if (!$user->admin || empty($conf->modulebuilder->enabled)) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -35,8 +36,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ -if ($action == "update") -{ +if ($action == "update") { $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); @@ -58,8 +58,9 @@ $reg = array(); if (preg_match('/set_(.*)/', $action, $reg)) { $code = $reg[1]; $values = GETPOST($code); - if (is_array($values)) + if (is_array($values)) { $values = implode(',', $values); + } if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -112,8 +113,7 @@ print ''; print "\n"; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // What is use case of this 2 options ? print ''; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index cbd0dc69375..101aa6db09c 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -27,7 +27,9 @@ * into the dirins directory. */ -if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test +if (!defined('NOSCANPOSTFORINJECTION')) { + define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test +} require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -48,17 +50,27 @@ $module = GETPOST('module', 'alpha'); $tab = GETPOST('tab', 'aZ09'); $tabobj = GETPOST('tabobj', 'alpha'); $propertykey = GETPOST('propertykey', 'alpha'); -if (empty($module)) $module = 'initmodule'; -if (empty($tab)) $tab = 'description'; -if (empty($tabobj)) $tabobj = 'newobjectifnoobj'; +if (empty($module)) { + $module = 'initmodule'; +} +if (empty($tab)) { + $tab = 'description'; +} +if (empty($tabobj)) { + $tabobj = 'newobjectifnoobj'; +} $file = GETPOST('file', 'alpha'); $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); // Security check -if (empty($conf->modulebuilder->enabled)) accessforbidden(); -if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden($langs->trans('ModuleBuilderNotAllowed')); +if (empty($conf->modulebuilder->enabled)) { + accessforbidden(); +} +if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) { + accessforbidden($langs->trans('ModuleBuilderNotAllowed')); +} // Dir for custom dirs @@ -68,14 +80,12 @@ $dirread = $dirins; $forceddirread = 0; $tmpdir = explode('@', $module); -if (!empty($tmpdir[1])) -{ +if (!empty($tmpdir[1])) { $module = $tmpdir[0]; $dirread = $tmpdir[1]; $forceddirread = 1; } -if (GETPOST('dirins', 'alpha')) -{ +if (GETPOST('dirins', 'alpha')) { $dirread = $dirins = GETPOST('dirins', 'alpha'); $forceddirread = 1; } @@ -84,9 +94,10 @@ $FILEFLAG = 'modulebuilder.txt'; $now = dol_now(); $newmask = 0; -if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; -if (empty($newmask)) // This should no happen -{ +if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) { + $newmask = $conf->global->MAIN_UMASK; +} +if (empty($newmask)) { // This should no happen $newmask = '0664'; } @@ -99,14 +110,15 @@ $form = new Form($db); // Define $listofmodules $dirsrootforscan = array($dirread); // Add also the core modules into the list of modules to show/edit -if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { $dirsrootforscan[] = DOL_DOCUMENT_ROOT; } +if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { + $dirsrootforscan[] = DOL_DOCUMENT_ROOT; +} // Search modules to edit $textforlistofdirs = ''."\n"; $listofmodules = array(); $i = 0; -foreach ($dirsrootforscan as $dirread) -{ +foreach ($dirsrootforscan as $dirread) { $moduletype = 'external'; if ($dirread == DOL_DOCUMENT_ROOT) { $moduletype = 'internal'; @@ -116,14 +128,12 @@ foreach ($dirsrootforscan as $dirread) if (is_array($dirsincustom) && count($dirsincustom) > 0) { foreach ($dirsincustom as $dircustomcursor) { $fullname = $dircustomcursor['fullname']; - if (dol_is_file($fullname.'/'.$FILEFLAG)) - { + if (dol_is_file($fullname.'/'.$FILEFLAG)) { // Get real name of module (MyModule instead of mymodule) $dirtoscanrel = basename($fullname).'/core/modules/'; $descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$'); - if (empty($descriptorfiles)) // If descriptor not found into module dir, we look into main module dir. - { + if (empty($descriptorfiles)) { // If descriptor not found into module dir, we look into main module dir. $dirtoscanrel = 'core/modules/'; $descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$'); } @@ -138,8 +148,7 @@ foreach ($dirsrootforscan as $dirread) $moduledescriptorfullpath = $descriptorcursor['fullname']; //var_dump($descriptorcursor); } - if ($modulenamewithcase) - { + if ($modulenamewithcase) { $listofmodules[$dircustomcursor['name']] = array( 'modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, @@ -153,8 +162,7 @@ foreach ($dirsrootforscan as $dirread) } } - if ($forceddirread && empty($listofmodules)) // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir - { + if ($forceddirread && empty($listofmodules)) { // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir $listofmodules[strtolower($module)] = array( 'modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', @@ -165,15 +173,24 @@ foreach ($dirsrootforscan as $dirread) // Show description of content $newdircustom = $dirins; - if (empty($newdircustom)) $newdircustom = img_warning(); + if (empty($newdircustom)) { + $newdircustom = img_warning(); + } // If dirread was forced to somewhere else, by using URL // htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product - if (empty($i)) $textforlistofdirs .= $langs->trans("DirScanned").' : '; - else $textforlistofdirs .= ', '; + if (empty($i)) { + $textforlistofdirs .= $langs->trans("DirScanned").' : '; + } else { + $textforlistofdirs .= ', '; + } $textforlistofdirs .= ''.$dirread.''; if ($dirread == DOL_DOCUMENT_ROOT) { - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL")); - if (!empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT)) $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MODULEBUILDER_ADD_DOCUMENT_ROOT")); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL")); + } + if (!empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT)) { + $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MODULEBUILDER_ADD_DOCUMENT_ROOT")); + } } $i++; } @@ -183,18 +200,15 @@ foreach ($dirsrootforscan as $dirread) * Actions */ -if ($dirins && $action == 'initmodule' && $modulename) -{ +if ($dirins && $action == 'initmodule' && $modulename) { $modulename = ucfirst($modulename); // Force first letter in uppercase - if (preg_match('/[^a-z0-9_]/i', $modulename)) - { + if (preg_match('/[^a-z0-9_]/i', $modulename)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($modulename); @@ -205,10 +219,8 @@ if ($dirins && $action == 'initmodule' && $modulename) $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); //dol_mkdir($destfile); - if ($result <= 0) - { - if ($result < 0) - { + if ($result <= 0) { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); @@ -218,8 +230,7 @@ if ($dirins && $action == 'initmodule' && $modulename) } } - if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) - { + if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } @@ -274,11 +285,9 @@ if ($dirins && $action == 'initmodule' && $modulename) } // Edit PHP files - if (!$error) - { + if (!$error) { $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); - foreach ($listofphpfilestoedit as $phpfileval) - { + foreach ($listofphpfilestoedit as $phpfileval) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -293,39 +302,45 @@ if ($dirins && $action == 'initmodule' && $modulename) ); if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) { + $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) { + $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) { + $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) { + $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; + } + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) { + $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; + } } $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } - if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README)) - { + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README)) { setEventMessages($langs->trans("ContentOfREADMECustomized"), null, 'warnings'); dol_delete_file($destdir.'/README.md'); file_put_contents($destdir.'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README); } } - if (!$error) - { + if (!$error) { setEventMessages('ModuleInitialized', null); $module = $modulename; $modulename = ''; } } -if ($dirins && $action == 'initapi' && !empty($module)) -{ +if ($dirins && $action == 'initapi' && !empty($module)) { $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; @@ -336,8 +351,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -360,8 +374,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initphpunit' && !empty($module)) -{ +if ($dirins && $action == 'initphpunit' && !empty($module)) { $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; @@ -371,8 +384,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php'; $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { //var_dump($phpfileval['fullname']); $arrayreplacement = array( 'mymodule'=>strtolower($modulename), @@ -410,8 +422,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { //var_dump($srcfile);var_dump($destfile); $result2 = dol_copy($srcfile2, $destfile2, 0, 0); - if ($result1 > 0 && $result2 > 0) - { + if ($result1 > 0 && $result2 > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -439,8 +450,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { } // TODO Enable in class the property $isextrafieldmanaged = 1 } -if ($dirins && $action == 'inithook' && !empty($module)) -{ +if ($dirins && $action == 'inithook' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/class'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/class/actions_mymodule.class.php'; @@ -448,8 +458,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -471,8 +480,7 @@ if ($dirins && $action == 'inithook' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'inittrigger' && !empty($module)) -{ +if ($dirins && $action == 'inittrigger' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/core/triggers'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php'; @@ -480,8 +488,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -503,8 +510,7 @@ if ($dirins && $action == 'inittrigger' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initwidget' && !empty($module)) -{ +if ($dirins && $action == 'initwidget' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/core/boxes'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/core/boxes/mymodulewidget1.php'; @@ -534,8 +540,7 @@ if ($dirins && $action == 'initwidget' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initcss' && !empty($module)) -{ +if ($dirins && $action == 'initcss' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/css'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/css/mymodule.css.php'; @@ -543,8 +548,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -572,8 +576,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) } } -if ($dirins && $action == 'initjs' && !empty($module)) -{ +if ($dirins && $action == 'initjs' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/js'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/js/mymodule.js.php'; @@ -581,8 +584,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -609,8 +611,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors'); } } -if ($dirins && $action == 'initcli' && !empty($module)) -{ +if ($dirins && $action == 'initcli' && !empty($module)) { dol_mkdir($dirins.'/'.strtolower($module).'/scripts'); $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcfile = $srcdir.'/scripts/mymodule.php'; @@ -618,8 +619,7 @@ if ($dirins && $action == 'initcli' && !empty($module)) //var_dump($srcfile);var_dump($destfile); $result = dol_copy($srcfile, $destfile, 0, 0); - if ($result > 0) - { + if ($result > 0) { $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); @@ -694,19 +694,16 @@ if ($dirins && $action == 'initdoc' && !empty($module)) { } } -if ($dirins && $action == 'addlanguage' && !empty($module)) -{ +if ($dirins && $action == 'addlanguage' && !empty($module)) { $newlangcode = GETPOST('newlangcode', 'aZ09'); $srcfile = $dirins.'/'.strtolower($module).'/langs/en_US'; $destfile = $dirins.'/'.strtolower($module).'/langs/'.$newlangcode; $result = dolCopyDir($srcfile, $destfile, 0, 0); } -if ($dirins && $action == 'confirm_removefile' && !empty($module)) -{ +if ($dirins && $action == 'confirm_removefile' && !empty($module)) { $relativefilename = dol_sanitizePathName(GETPOST('file', 'none')); - if ($relativefilename) - { + if ($relativefilename) { $dirnametodelete = dirname($relativefilename); $filetodelete = $dirins.'/'.$relativefilename; $dirtodelete = $dirins.'/'.$dirnametodelete; @@ -715,11 +712,12 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) if (!$result) { setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors'); } else { - if (dol_is_dir_empty($dirtodelete)) dol_delete_dir($dirtodelete); + if (dol_is_dir_empty($dirtodelete)) { + dol_delete_dir($dirtodelete); + } // Update descriptor file to comment file - if (in_array($tab, array('css', 'js'))) - { + if (in_array($tab, array('css', 'js'))) { $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); @@ -729,12 +727,10 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) } // Build the $fields array from SQL table (initfromtablename) -if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) -{ +if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) { $tablename = GETPOST('initfromtablename', 'alpha'); $_results = $db->DDLDescTable($tablename); - if (empty($_results)) - { + if (empty($_results)) { setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors'); } else { /** @@ -780,66 +776,133 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $string = 'public $fields=array('."\n"; $string .= "
"; $i = 10; - while ($obj = $db->fetch_object($_results)) - { + while ($obj = $db->fetch_object($_results)) { // fieldname $fieldname = $obj->Field; // type $type = $obj->Type; - if ($type == 'int(11)') $type = 'integer'; - if ($type == 'float') $type = 'real'; - if (strstr($type, 'tinyint')) $type = 'integer'; - if ($obj->Field == 'fk_soc') $type = 'integer:Societe:societe/class/societe.class.php'; - if (preg_match('/^fk_proj/', $obj->Field)) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; - if (preg_match('/^fk_prod/', $obj->Field)) $type = 'integer:Product:product/class/product.class.php:1'; - if ($obj->Field == 'fk_warehouse') $type = 'integer:Entrepot:product/stock/class/entrepot.class.php'; - if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) $type = 'integer:User:user/class/user.class.php'; + if ($type == 'int(11)') { + $type = 'integer'; + } + if ($type == 'float') { + $type = 'real'; + } + if (strstr($type, 'tinyint')) { + $type = 'integer'; + } + if ($obj->Field == 'fk_soc') { + $type = 'integer:Societe:societe/class/societe.class.php'; + } + if (preg_match('/^fk_proj/', $obj->Field)) { + $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; + } + if (preg_match('/^fk_prod/', $obj->Field)) { + $type = 'integer:Product:product/class/product.class.php:1'; + } + if ($obj->Field == 'fk_warehouse') { + $type = 'integer:Entrepot:product/stock/class/entrepot.class.php'; + } + if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) { + $type = 'integer:User:user/class/user.class.php'; + } // notnull $notnull = ($obj->Null == 'YES' ? 0 : 1); - if ($fieldname == 'fk_user_modif') $notnull = -1; + if ($fieldname == 'fk_user_modif') { + $notnull = -1; + } // label $label = preg_replace('/_/', '', ucfirst($fieldname)); - if ($fieldname == 'rowid') $label = 'TechnicalID'; - if ($fieldname == 'import_key') $label = 'ImportId'; - if ($fieldname == 'fk_soc') $label = 'ThirdParty'; - if ($fieldname == 'tms') $label = 'DateModification'; - if ($fieldname == 'datec') $label = 'DateCreation'; - if ($fieldname == 'date_valid') $label = 'DateValidation'; - if ($fieldname == 'datev') $label = 'DateValidation'; - if ($fieldname == 'note_private') $label = 'NotePublic'; - if ($fieldname == 'note_public') $label = 'NotePrivate'; - if ($fieldname == 'fk_user_creat') $label = 'UserAuthor'; - if ($fieldname == 'fk_user_modif') $label = 'UserModif'; - if ($fieldname == 'fk_user_valid') $label = 'UserValidation'; + if ($fieldname == 'rowid') { + $label = 'TechnicalID'; + } + if ($fieldname == 'import_key') { + $label = 'ImportId'; + } + if ($fieldname == 'fk_soc') { + $label = 'ThirdParty'; + } + if ($fieldname == 'tms') { + $label = 'DateModification'; + } + if ($fieldname == 'datec') { + $label = 'DateCreation'; + } + if ($fieldname == 'date_valid') { + $label = 'DateValidation'; + } + if ($fieldname == 'datev') { + $label = 'DateValidation'; + } + if ($fieldname == 'note_private') { + $label = 'NotePublic'; + } + if ($fieldname == 'note_public') { + $label = 'NotePrivate'; + } + if ($fieldname == 'fk_user_creat') { + $label = 'UserAuthor'; + } + if ($fieldname == 'fk_user_modif') { + $label = 'UserModif'; + } + if ($fieldname == 'fk_user_valid') { + $label = 'UserValidation'; + } // visible $visible = -1; - if ($fieldname == 'entity') $visible = -2; - if ($fieldname == 'import_key') $visible = -2; - if ($fieldname == 'fk_user_creat') $visible = -2; - if ($fieldname == 'fk_user_modif') $visible = -2; - if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) $visible = 0; + if ($fieldname == 'entity') { + $visible = -2; + } + if ($fieldname == 'import_key') { + $visible = -2; + } + if ($fieldname == 'fk_user_creat') { + $visible = -2; + } + if ($fieldname == 'fk_user_modif') { + $visible = -2; + } + if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) { + $visible = 0; + } // enabled $enabled = 1; // default $default = ''; - if ($fieldname == 'entity') $default = 1; + if ($fieldname == 'entity') { + $default = 1; + } // position $position = $i; - if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) $position = 500; - if ($fieldname == 'import_key') $position = 900; + if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) { + $position = 500; + } + if ($fieldname == 'import_key') { + $position = 900; + } // index $index = 0; - if ($fieldname == 'entity') $index = 1; + if ($fieldname == 'entity') { + $index = 1; + } $string .= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; - if ($default != '') $string .= " 'default'=>".$default.","; + if ($default != '') { + $string .= " 'default'=>".$default.","; + } $string .= " 'enabled'=>".$enabled.","; $string .= " 'visible'=>".$visible; - if ($notnull) $string .= ", 'notnull'=>".$notnull; - if ($fieldname == 'ref') $string .= ", 'showoncombobox'=>1"; + if ($notnull) { + $string .= ", 'notnull'=>".$notnull; + } + if ($fieldname == 'ref') { + $string .= ", 'showoncombobox'=>1"; + } $string .= ", 'position'=>".$position; - if ($index) $string .= ", 'index'=>".$index; + if ($index) { + $string .= ", 'index'=>".$index; + } $string .= "),\n"; $string .= "
"; $i += 5; @@ -851,15 +914,13 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', } } -if ($dirins && $action == 'initobject' && $module && $objectname) -{ +if ($dirins && $action == 'initobject' && $module && $objectname) { $objectname = ucfirst($objectname); $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; $moduletype = $listofmodules[strtolower($module)]['moduletype']; - if (preg_match('/[^a-z0-9_]/i', $objectname)) - { + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); $tabobj = 'newobject'; @@ -882,15 +943,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) dol_mkdir($destdir.'/sql'); // Scan dir class to find if an object with same name already exists. - if (!$error) - { + if (!$error) { $dirlist = dol_dir_list($destdir.'/class', 'files', 0, '\.txt$'); $alreadyfound = false; - foreach ($dirlist as $key => $val) - { + foreach ($dirlist as $key => $val) { $filefound = preg_replace('/\.txt$/', '', $val['name']); - if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) - { + if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) { $alreadyfound = true; $error++; setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); @@ -899,8 +957,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (!$error) - { + if (!$error) { // Copy some files $filetogenerate = array( 'myobject_card.php'=>strtolower($objectname).'_card.php', @@ -922,8 +979,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php', ); - if (GETPOST('includerefgeneration', 'aZ09')) - { + if (GETPOST('includerefgeneration', 'aZ09')) { dol_mkdir($destdir.'/core/modules/'.strtolower($module)); $filetogenerate += array( @@ -932,8 +988,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'core/modules/mymodule/modules_myobject.php'=>'core/modules/'.strtolower($module).'/modules_'.strtolower($objectname).'.php', ); } - if (GETPOST('includedocgeneration', 'aZ09')) - { + if (GETPOST('includedocgeneration', 'aZ09')) { dol_mkdir($destdir.'/core/modules/'.strtolower($module)); dol_mkdir($destdir.'/core/modules/'.strtolower($module).'/doc'); @@ -943,13 +998,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) ); } - foreach ($filetogenerate as $srcfile => $destfile) - { + foreach ($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); - if ($result <= 0) - { - if ($result < 0) - { + if ($result <= 0) { + if ($result < 0) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); @@ -999,17 +1051,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); $firstobjectname = ''; - foreach ($listofobject as $fileobj) - { - if (preg_match('/^api_/', $fileobj['name'])) continue; - if (preg_match('/^actions_/', $fileobj['name'])) continue; + foreach ($listofobject as $fileobj) { + if (preg_match('/^api_/', $fileobj['name'])) { + continue; + } + if (preg_match('/^actions_/', $fileobj['name'])) { + continue; + } $tmpcontent = file_get_contents($fileobj['fullname']); $reg = array(); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) - { + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { $objectnameloop = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectnameloop; + if (empty($firstobjectname)) { + $firstobjectname = $objectnameloop; + } } // Regenerate left menu entry in descriptor for $objectname @@ -1070,11 +1126,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (!$error) - { + if (!$error) { // Edit PHP files to make replacement - foreach ($filetogenerate as $destfile) - { + foreach ($filetogenerate as $destfile) { $phpfileval['fullname'] = $destdir.'/'.$destfile; //var_dump($phpfileval['fullname']); @@ -1094,75 +1148,71 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } } } - if (!$error) - { + if (!$error) { // Edit the class file to write properties $object = rebuildObjectClass($destdir, $module, $objectname, $newmask); - if (is_numeric($object) && $object < 0) $error++; + if (is_numeric($object) && $object < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { // Edit sql with new properties $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); $tabobj = $objectname; } } -if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) -{ +if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) { $objectname = $tabobj; $arrayoftables = array(); - if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); - if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; + if ($action == 'droptable') { + $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); + } + if ($action == 'droptableextrafields') { + $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; + } - foreach ($arrayoftables as $tabletodrop) - { + foreach ($arrayoftables as $tabletodrop) { $nb = -1; $sql = "SELECT COUNT(*) as nb FROM ".$tabletodrop; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $nb = $obj->nb; } } else { - if ($db->lasterrno() == 'DB_ERROR_NOSUCHTABLE') - { + if ($db->lasterrno() == 'DB_ERROR_NOSUCHTABLE') { setEventMessages($langs->trans("TableDoesNotExists", $tabletodrop), null, 'warnings'); } else { dol_print_error($db); } } - if ($nb == 0) - { + if ($nb == 0) { $resql = $db->DDLDropTable($tabletodrop); //var_dump($resql); setEventMessages($langs->trans("TableDropped", $tabletodrop), null, 'mesgs'); - } elseif ($nb > 0) - { + } elseif ($nb > 0) { setEventMessages($langs->trans("TableNotEmptyDropCanceled", $tabletodrop), null, 'warnings'); } } } -if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) -{ +if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { $error = 0; $objectname = $tabobj; @@ -1175,26 +1225,21 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) dol_mkdir($destdir); // We click on add property - if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) - { - if (!GETPOST('propname', 'aZ09')) - { + if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { + if (!GETPOST('propname', 'aZ09')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name")), null, 'errors'); } - if (!GETPOST('proplabel', 'alpha')) - { + if (!GETPOST('proplabel', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!GETPOST('proptype', 'alpha')) - { + if (!GETPOST('proptype', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - if (!$error) - { + if (!$error) { $addfieldentry = array( 'name'=>GETPOST('propname', 'aZ09'), 'label'=>GETPOST('proplabel', 'alpha'), 'type'=>GETPOST('proptype', 'alpha'), 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' @@ -1203,8 +1248,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha') ); - if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) - { + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { $addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true); } } @@ -1217,31 +1261,26 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) }*/ // Edit the class file to write properties - if (!$error) - { + if (!$error) { $moduletype = 'external'; $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry, $moduletype); - if (is_numeric($object) && $object <= 0) - { + if (is_numeric($object) && $object <= 0) { $error++; } } // Edit sql with new properties - if (!$error) - { + if (!$error) { $moduletype = 'external'; $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype); - if ($result <= 0) - { + if ($result <= 0) { $error++; } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); @@ -1253,8 +1292,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) } } -if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) -{ +if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) { $objectname = $tabobj; $srcdir = $dirread.'/'.strtolower($module); @@ -1262,21 +1300,22 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) dol_mkdir($destdir); // Edit the class file to write properties - if (!$error) - { + if (!$error) { $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey); - if (is_numeric($object) && $object <= 0) $error++; + if (is_numeric($object) && $object <= 0) { + $error++; + } } // Edit sql with new properties - if (!$error) - { + if (!$error) { $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); - if ($result <= 0) $error++; + if ($result <= 0) { + $error++; + } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); @@ -1288,16 +1327,13 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) } } -if ($dirins && $action == 'confirm_deletemodule') -{ - if (preg_match('/[^a-z0-9_]/i', $module)) - { +if ($dirins && $action == 'confirm_deletemodule') { + if (preg_match('/[^a-z0-9_]/i', $module)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $modulelowercase = strtolower($module); // Dir for module @@ -1305,8 +1341,7 @@ if ($dirins && $action == 'confirm_deletemodule') $result = dol_delete_dir_recursive($dir); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); } else { setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); @@ -1317,16 +1352,13 @@ if ($dirins && $action == 'confirm_deletemodule') $module = 'deletemodule'; } -if ($dirins && $action == 'confirm_deleteobject' && $objectname) -{ - if (preg_match('/[^a-z0-9_]/i', $objectname)) - { +if ($dirins && $action == 'confirm_deleteobject' && $objectname) { + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - if (!$error) - { + if (!$error) { $modulelowercase = strtolower($module); $objectlowercase = strtolower($objectname); @@ -1360,15 +1392,15 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) ); $resultko = 0; - foreach ($filetodelete as $filetodelete) - { + foreach ($filetodelete as $filetodelete) { $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); $resulttmp = dol_delete_file($dir.'/'.$filetodelete.'.back', 0, 0, 1); - if (!$resulttmp) $resultko++; + if (!$resulttmp) { + $resultko++; + } } - if ($resultko == 0) - { + if ($resultko == 0) { setEventMessages($langs->trans("FilesDeleted"), null); } else { setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); @@ -1380,8 +1412,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) } -if ($dirins && $action == 'generatepackage') -{ +if ($dirins && $action == 'generatepackage') { $modulelowercase = strtolower($module); // Dir for module @@ -1393,12 +1424,10 @@ if ($dirins && $action == 'generatepackage') dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); $class = 'mod'.$module; - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); - } catch (Exception $e) - { + } catch (Exception $e) { $error++; dol_print_error($e->getMessage()); } @@ -1410,22 +1439,21 @@ if ($dirins && $action == 'generatepackage') } $arrayversion = explode('.', $moduleobj->version, 3); - if (count($arrayversion)) - { + if (count($arrayversion)) { $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; - if ($dirofmodule) - { - if (!dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); + if ($dirofmodule) { + if (!dol_is_dir($dirofmodule)) { + dol_mkdir($dirofmodule); + } $result = dol_compress_dir($dir, $outputfilezip, 'zip', '', $modulelowercase); } else { $result = -1; } - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); } else { $error++; @@ -1439,16 +1467,14 @@ if ($dirins && $action == 'generatepackage') } } -if ($dirins && $action == 'generatedoc') -{ +if ($dirins && $action == 'generatedoc') { $FILENAMEDOC = strtolower($module).'.html'; $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc'; $util = new Utils($db); $result = $util->generateDoc($module); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null); } else { setEventMessages($util->error, $util->errors, 'errors'); @@ -1457,39 +1483,42 @@ if ($dirins && $action == 'generatedoc') // Save file -if ($action == 'savefile' && empty($cancel)) -{ +if ($action == 'savefile' && empty($cancel)) { $relofcustom = basename($dirins); - if ($relofcustom) - { + if ($relofcustom) { // Check that relative path ($file) start with name 'custom' - if (!preg_match('/^'.$relofcustom.'/', $file)) $file = $relofcustom.'/'.$file; + if (!preg_match('/^'.$relofcustom.'/', $file)) { + $file = $relofcustom.'/'.$file; + } $pathoffile = dol_buildpath($file, 0); $pathoffilebackup = dol_buildpath($file.'.back', 0); // Save old version - if (dol_is_file($pathoffile)) - { + if (dol_is_file($pathoffile)) { dol_copy($pathoffile, $pathoffilebackup, 0, 1); } $check = 'restricthtml'; $srclang = dol_mimetype($pathoffile, '', 3); - if ($srclang == 'md') $check = 'restricthtml'; - if ($srclang == 'lang') $check = 'restricthtml'; - if ($srclang == 'php') $check = 'none'; + if ($srclang == 'md') { + $check = 'restricthtml'; + } + if ($srclang == 'lang') { + $check = 'restricthtml'; + } + if ($srclang == 'php') { + $check = 'none'; + } $content = GETPOST('editfilecontent', $check); // Save file on disk - if ($content) - { + if ($content) { dol_delete_file($pathoffile); $result = file_put_contents($pathoffile, $content); - if ($result) - { + if ($result) { @chmod($pathoffile, octdec($newmask)); setEventMessages($langs->trans("FileSaved"), null); @@ -1505,32 +1534,37 @@ if ($action == 'savefile' && empty($cancel)) } // Enable module -if ($action == 'set' && $user->admin) -{ +if ($action == 'set' && $user->admin) { $param = ''; - if ($module) $param .= '&module='.urlencode($module); - if ($tab) $param .= '&tab='.urlencode($tab); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $value = GETPOST('value', 'alpha'); $resarray = activateModule($value); - if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); - else { + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { //var_dump($resarray);exit; - if ($resarray['nbperms'] > 0) - { + if ($resarray['nbperms'] > 0) { $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; $resqltmp = $db->query($tmpsql); - if ($resqltmp) - { + if ($resqltmp) { $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; - if ($obj && $obj->nb > 1) - { + if ($obj && $obj->nb > 1) { $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); setEventMessages($msg, null, 'warnings'); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } } header("Location: ".$_SERVER["PHP_SELF"]."?".$param); @@ -1538,16 +1572,23 @@ if ($action == 'set' && $user->admin) } // Disable module -if ($action == 'reset' && $user->admin) -{ +if ($action == 'reset' && $user->admin) { $param = ''; - if ($module) $param .= '&module='.urlencode($module); - if ($tab) $param .= '&tab='.urlencode($tab); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $value = GETPOST('value', 'alpha'); $result = unActivateModule($value); - if ($result) setEventMessages($result, null, 'errors'); + if ($result) { + setEventMessages($result, null, 'errors'); + } header("Location: ".$_SERVER["PHP_SELF"]."?".$param); exit; } @@ -1562,8 +1603,7 @@ $form = new Form($db); $formadmin = new FormAdmin($db); // Set dir where external modules are installed -if (!dol_is_dir($dirins)) -{ +if (!dol_is_dir($dirins)) { dol_mkdir($dirins); } $dirins_ok = (dol_is_dir($dirins)); @@ -1592,15 +1632,12 @@ print '
'; $message = ''; -if (!$dirins) -{ +if (!$dirins) { $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); $allowfromweb = -1; } else { - if ($dirins_ok) - { - if (!is_writable(dol_osencode($dirins))) - { + if ($dirins_ok) { + if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins)); $allowfromweb = 0; @@ -1610,8 +1647,7 @@ if (!$dirins) $allowfromweb = 0; } } -if ($message) -{ +if ($message) { print $message; } @@ -1624,8 +1660,7 @@ $error = 0; $moduleobj = null; -if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') -{ +if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $modulelowercase = strtolower($module); $loadclasserrormessage = ''; @@ -1643,8 +1678,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') $loadclasserrormessage .= 'Line: '.$e->getLine()."
\n"; } - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); } catch (Exception $e) { @@ -1652,7 +1686,9 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') print $e->getMessage(); } } else { - if (empty($forceddirread)) $error++; + if (empty($forceddirread)) { + $error++; + } $langs->load("errors"); print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; print $loadclasserrormessage; @@ -1680,13 +1716,18 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $const_name = 'MAIN_MODULE_'.strtoupper($module); $param = ''; - if ($tab) $param .= '&tab='.urlencode($tab); - if ($module) $param .= '&module='.urlencode($module); - if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); + if ($tab) { + $param .= '&tab='.urlencode($tab); + } + if ($module) { + $param .= '&module='.urlencode($module); + } + if ($tabobj) { + $param .= '&tabobj='.urlencode($tabobj); + } $urltomodulesetup = ''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; - if (!empty($conf->global->$const_name)) // If module is already activated - { + if (!empty($conf->global->$const_name)) { // If module is already activated $linktoenabledisable .= ''; $linktoenabledisable .= img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); $linktoenabledisable .= ''; @@ -1694,22 +1735,21 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $objMod = $moduleobj; $backtourlparam = ''; $backtourlparam .= ($backtourlparam ? '&' : '?').'module='.$module; // No urlencode here, done later - if ($tab) $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later + if ($tab) { + $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later + } $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; $regs = array(); - if (is_array($objMod->config_page_url)) - { + if (is_array($objMod->config_page_url)) { $i = 0; - foreach ($objMod->config_page_url as $page) - { + foreach ($objMod->config_page_url as $page) { $urlpage = $page; if ($i++) { $linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").''; // print ''.ucfirst($page).' '; } else { - if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; } else { @@ -1729,14 +1769,12 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $linktoenabledisable .= "\n"; } - if (!empty($conf->$modulelowercase->enabled)) - { + if (!empty($conf->$modulelowercase->enabled)) { $modulestatusinfo = $form->textwithpicto('', $langs->trans("Warning").' : '.$langs->trans("ModuleIsLive"), -1, 'warning'); } // Loop to show tab of each module - foreach ($listofmodules as $tmpmodule => $tmpmodulearray) - { + foreach ($listofmodules as $tmpmodule => $tmpmodulearray) { $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); $head[$h][1] = $tmpmodulearray['modulenamewithcase']; $head[$h][2] = $tmpmodulearray['modulenamewithcase']; @@ -1757,8 +1795,7 @@ $h++; print dol_get_fiche_head($head, $module, '', -1, '', 0, $infomodulesfound, '', 8); // Modules -if ($module == 'initmodule') -{ +if ($module == 'initmodule') { // New module print ''; print ''; @@ -1787,8 +1824,7 @@ if ($module == 'initmodule') print ''; } elseif (!empty($module)) { // Tabs for module - if (!$error) - { + if (!$error) { $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; $head2 = array(); @@ -1877,20 +1913,17 @@ if ($module == 'initmodule') // Note module is inside $dirread - if ($tab == 'description') - { + if ($tab == 'description') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $pathtofilereadme = $modulelowercase.'/README.md'; $pathtochangelog = $modulelowercase.'/ChangeLog.md'; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Description - level 2 print ''.$langs->trans("ModuleBuilderDesc".$tab).''; $infoonmodulepath = ''; - if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) - { + if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) { $infoonmodulepath = ''.$langs->trans("RealPathOfModule").' :'.realpath($dirread.'/'.$modulelowercase).'
'; print ' '.$infoonmodulepath; } @@ -1916,8 +1949,7 @@ if ($module == 'initmodule') print load_fiche_titre($langs->trans("DescriptorFile"), '', ''); - if (!empty($moduleobj)) - { + if (!empty($moduleobj)) { print '
'; print '
'; @@ -1978,16 +2010,18 @@ if ($module == 'initmodule') print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; } - if (!empty($moduleobj)) - { + if (!empty($moduleobj)) { print '

'; // Readme file print load_fiche_titre($langs->trans("ReadmeFile"), '', ''); print ''; - if (dol_is_file($dirread.'/'.$pathtofilereadme)) print '
'.$moduleobj->getDescLong().'
'; - else print ''.$langs->trans("ErrorFileNotFound", $pathtofilereadme).''; + if (dol_is_file($dirread.'/'.$pathtofilereadme)) { + print '
'.$moduleobj->getDescLong().'
'; + } else { + print ''.$langs->trans("ErrorFileNotFound", $pathtofilereadme).''; + } print '

'; @@ -1995,16 +2029,18 @@ if ($module == 'initmodule') print load_fiche_titre($langs->trans("ChangeLog"), '', ''); print ''; - if (dol_is_file($dirread.'/'.$pathtochangelog)) print '
'.$moduleobj->getChangeLog().'
'; - else print ''.$langs->trans("ErrorFileNotFound", $pathtochangelog).''; + if (dol_is_file($dirread.'/'.$pathtochangelog)) { + print '
'.$moduleobj->getChangeLog().'
'; + } else { + print ''.$langs->trans("ErrorFileNotFound", $pathtochangelog).''; + } } print dol_get_fiche_end(); } else { // Edit text file $fullpathoffile = dol_buildpath($file, 0, 1); // Description - level 2 - if ($fullpathoffile) - { + if ($fullpathoffile) { $content = file_get_contents($fullpathoffile); } @@ -2035,10 +2071,8 @@ if ($module == 'initmodule') print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Level 2 } - if ($tab == 'languages') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'languages') { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("LanguageDefDesc").'
'; print '
'; @@ -2059,8 +2093,7 @@ if ($module == 'initmodule') $langfiles = dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); print '
'; - print $langs->trans('CustomerCode').''; - print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print '
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); + $tmpcheck = $object->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; print $langs->trans('SupplierCode').''; - print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); + $tmpcheck = $object->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } print '
".price(price2num($objp->selling_price, 'MT'))."".price(price2num(($objp->type == 2 ? -1 : 1) * $objp->buying_price, 'MT'))."".$sign.price(price2num($objp->marge, 'MT'))."".(($marginRate === '') ? 'n/a' : $sign.price(price2num($marginRate, 'MT'))."%")."".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).'
".price(price2num($cumul_vente, 'MT'))."".price(price2num($cumul_achat, 'MT'))."".price(price2num($totalMargin, 'MT'))."".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")." 
'.$langs->trans("Value").'
'; - foreach ($langfiles as $langfile) - { + foreach ($langfiles as $langfile) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; print '\n"; - if (is_array($dicts) && is_array($dicts['tabname'])) - { + if (is_array($dicts) && is_array($dicts['tabname'])) { $i = 0; $maxi = count($dicts['tabname']); - while ($i < $maxi) - { + while ($i < $maxi) { print ''; print ''; print ''; @@ -2617,8 +2648,7 @@ if ($module == 'initmodule') print ''; // List of existing properties - foreach ($properties as $propkey => $propval) - { + foreach ($properties as $propkey => $propval) { /* If from Reflection if ($propval->class == $tabobj) { @@ -2723,8 +2753,7 @@ if ($module == 'initmodule') print ''; print ''; print ''; @@ -2732,20 +2761,19 @@ if ($module == 'initmodule') print ''; } } else { - if ($tab == 'specifications') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'specifications') { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("SpecDefDesc").'
'; print '
'; $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); - foreach ($specs as $spec) - { + foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; $format = 'asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; + if (preg_match('/\.md$/i', $spec['name'])) { + $format = 'markdown'; + } print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -2788,13 +2816,11 @@ if ($module == 'initmodule') } else { print ''; } - } catch (Exception $e) - { + } catch (Exception $e) { print $e->getMessage(); } } else { - if (empty($forceddirread)) - { + if (empty($forceddirread)) { $fullpathoffile = dol_buildpath($file, 0); } else { $fullpathoffile = $dirread.'/'.$file; @@ -2827,14 +2853,12 @@ if ($module == 'initmodule') print dol_get_fiche_end(); // Level 3 } - if ($tab == 'menus') - { + if ($tab == 'menus') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $menus = $moduleobj->menu; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''; $htmlhelp = $langs->trans("MenusDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Menus').''); print $form->textwithpicto($langs->trans("MenusDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; @@ -2873,10 +2897,8 @@ if ($module == 'initmodule') print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'right '); print "\n"; - if (count($menus)) - { - foreach ($menus as $menu) - { + if (count($menus)) { + foreach ($menus as $menu) { print '
'; print ''; } } else { - print ''; + print ''; } print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; @@ -2098,14 +2131,12 @@ if ($module == 'initmodule') } } - if ($tab == 'dictionaries') - { + if ($tab == 'dictionaries') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $dicts = $moduleobj->dictionaries; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''; $htmlhelp = $langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').''); print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; @@ -2146,12 +2177,10 @@ if ($module == 'initmodule') print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "
'; @@ -2231,8 +2260,7 @@ if ($module == 'initmodule') } } - if ($tab == 'objects') - { + if ($tab == 'objects') { $head3 = array(); $h = 0; @@ -2248,17 +2276,21 @@ if ($module == 'initmodule') $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); $firstobjectname = ''; - foreach ($listofobject as $fileobj) - { - if (preg_match('/^api_/', $fileobj['name'])) continue; - if (preg_match('/^actions_/', $fileobj['name'])) continue; + foreach ($listofobject as $fileobj) { + if (preg_match('/^api_/', $fileobj['name'])) { + continue; + } + if (preg_match('/^actions_/', $fileobj['name'])) { + continue; + } $tmpcontent = file_get_contents($fileobj['fullname']); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) - { + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); $objectname = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectname; + if (empty($firstobjectname)) { + $firstobjectname = $objectname; + } $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname; $head3[$h][1] = $objectname; @@ -2273,16 +2305,17 @@ if ($module == 'initmodule') $h++; // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. - if ($tabobj == 'newobjectifnoobj') - { - if ($firstobjectname) $tabobj = $firstobjectname; - else $tabobj = 'newobject'; + if ($tabobj == 'newobjectifnoobj') { + if ($firstobjectname) { + $tabobj = $firstobjectname; + } else { + $tabobj = 'newobject'; + } } print dol_get_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 - if ($tabobj == 'newobject') - { + if ($tabobj == 'newobject') { // New object tab print '
'; print ''; @@ -2324,19 +2357,22 @@ if ($module == 'initmodule') print '
'; } else { // tabobj = module - if ($action == 'deleteproperty') - { + if ($action == 'deleteproperty') { $formconfirm = $form->formconfirm( $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey', 'alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), - $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey', 'alpha')), 'confirm_deleteproperty', '', 0, 1 - ); + $langs->trans('Delete'), + $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey', 'alpha')), + 'confirm_deleteproperty', + '', + 0, + 1 + ); // Print form confirm print $formconfirm; } - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { try { //$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; @@ -2377,8 +2413,7 @@ if ($module == 'initmodule') $realpathtopicto = $dirread.'/'.$pathtopicto; $realpathtoscript = $dirread.'/'.$pathtoscript; - if (empty($realpathtoapi)) // For compatibility with some old modules - { + if (empty($realpathtoapi)) { // For compatibility with some old modules $pathtoapi = strtolower($module).'/class/api_'.strtolower($module).'s.class.php'; $realpathtoapi = $dirread.'/'.$pathtoapi; } @@ -2392,15 +2427,14 @@ if ($module == 'initmodule') print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').$pathtoapi.($realpathtoapi ? '' : '').''; if (dol_is_file($realpathtoapi)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; - print '   '; - if (empty($conf->global->$const_name)) // If module is not activated - { - print ''.$langs->trans("GoToApiExplorer").''; - } else { - print ''.$langs->trans("GoToApiExplorer").''; - } + print ' '; + print ''.img_picto($langs->trans("Delete"), 'delete').''; + print '   '; + if (empty($conf->global->$const_name)) { // If module is not activated + print ''.$langs->trans("GoToApiExplorer").''; + } else { + print ''.$langs->trans("GoToApiExplorer").''; + } } else { //print ''.$langs->trans("FileNotYetGenerated").' '; print ''; @@ -2514,26 +2548,24 @@ if ($module == 'initmodule') print '


'; - if (function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! + if (function_exists('opcache_invalidate')) { + opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! + } - if (empty($forceddirread) && empty($dirread)) - { + if (empty($forceddirread) && empty($dirread)) { $result = dol_include_once($pathtoclass); } else { $result = @include_once $dirread.'/'.$pathtoclass; } - if (class_exists($tabobj)) - { + if (class_exists($tabobj)) { try { $tmpobjet = @new $tabobj($db); - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); } } - if (!empty($tmpobjet)) - { + if (!empty($tmpobjet)) { $reflector = new ReflectionClass($tabobj); $reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars $reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars @@ -2588,8 +2620,7 @@ if ($module == 'initmodule') //$properties = dol_sort_array($tmpobjet->fields, 'position'); $properties = dol_sort_array($reflectorpropdefault['fields'], 'position'); - if (!empty($properties)) - { + if (!empty($properties)) { // Line to add a property print '
'; - if ($propname != 'rowid') - { + if ($propname != 'rowid') { print ''.img_delete().''; } print '
'.$langs->trans('Failed to init the object with the new.').'
'; @@ -2930,7 +2952,7 @@ if ($module == 'initmodule') print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; @@ -2963,14 +2985,12 @@ if ($module == 'initmodule') } } - if ($tab == 'permissions') - { + if ($tab == 'permissions') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $perms = $moduleobj->rights; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''; $htmlhelp = $langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').''); print $form->textwithpicto($langs->trans("PermissionsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; @@ -3001,10 +3021,8 @@ if ($module == 'initmodule') print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "\n"; - if (count($perms)) - { - foreach ($perms as $perm) - { + if (count($perms)) { + foreach ($perms as $perm) { print ''; print ''; @@ -3059,10 +3077,8 @@ if ($module == 'initmodule') } } - if ($tab == 'hooks') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'hooks') { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("HooksDefDesc").'
'; print '
'; @@ -3078,8 +3094,7 @@ if ($module == 'initmodule') print ''; $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; print ' '.$langs->trans("HooksFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; print ''; print ''.img_picto($langs->trans("Edit"), 'edit').' '; @@ -3116,15 +3131,13 @@ if ($module == 'initmodule') } } - if ($tab == 'triggers') - { + if ($tab == 'triggers') { require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("TriggerDefDesc").'
'; print '
'; @@ -3137,10 +3150,8 @@ if ($module == 'initmodule') print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; - if (!empty($triggers)) - { - foreach ($triggers as $trigger) - { + if (!empty($triggers)) { + foreach ($triggers as $trigger) { $pathtofile = $trigger['relpath']; print ''; @@ -3184,10 +3195,8 @@ if ($module == 'initmodule') } } - if ($tab == 'css') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'css') { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("CSSDesc").'
'; print '
'; @@ -3196,8 +3205,7 @@ if ($module == 'initmodule') print ''; $pathtohook = strtolower($module).'/css/'.strtolower($module).'.css.php'; print ' '.$langs->trans("CSSFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; @@ -3232,10 +3240,8 @@ if ($module == 'initmodule') } } - if ($tab == 'js') - { - if ($action != 'editfile' || empty($file)) - { + if ($tab == 'js') { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("JSDesc").'
'; print '
'; @@ -3244,8 +3250,7 @@ if ($module == 'initmodule') print ''; $pathtohook = strtolower($module).'/js/'.strtolower($module).'.js.php'; print ' '.$langs->trans("JSFile").' : '; - if (dol_is_file($dirins.'/'.$pathtohook)) - { + if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; @@ -3280,22 +3285,18 @@ if ($module == 'initmodule') } } - if ($tab == 'widgets') - { + if ($tab == 'widgets') { require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("WidgetDesc").'
'; print '
'; print ''; - if (!empty($widgets)) - { - foreach ($widgets as $widget) - { + if (!empty($widgets)) { + foreach ($widgets as $widget) { $pathtofile = $widget['relpath']; print ''; print ''; print ''; + if ($permissiontoupdatecost) { + if (empty($bomcost)) { + print ''; + } else { + print ''; + } + } print ''; print ''; if ($conf->productbatch->enabled) { print ''; print ''; } print ''; - if (!empty($object->lines)) - { + if (!empty($object->lines)) { $nblinetoproduce = 0; foreach ($object->lines as $line) { if ($line->role == 'toproduce') { @@ -899,6 +982,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); + if (empty($bomcost)) { + $bomcost = $tmpproduct->pmp; + } + $arrayoflines = $object->fetchLinesLinked('produced', $line->id); $alreadyproduced = 0; foreach ($arrayoflines as $line2) { @@ -916,6 +1003,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$tmpproduct->label.''; print ''; print ''; + if ($permissiontoupdatecost) { + print ''; + } print ''; @@ -948,14 +1044,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print ''; print ''; + // Qty print ''; + // Cost price + if ($permissiontoupdatecost) { + print ''; + } + // Qty already produced print ''; print ''; if ($conf->productbatch->enabled) { @@ -975,8 +1081,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { + $preselected = 0; + } print ''; + if ($permissiontoupdatecost) { + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost)); + print ''; + } else { + print ''; + } + } print ''; print ''; + // Batch number in same column than the stock movement picto print ''; $selected = 1; -if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected = 0; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { + $selected = 0; +} print ''; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index bb4df7060e9..0bf7fc6a252 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -121,14 +121,15 @@ class MultiCurrency extends CommonObject $error = 0; - if (self::checkCodeAlreadyExists($this->code)) - { + if (self::checkCodeAlreadyExists($this->code)) { $error++; $this->errors[] = $langs->trans('multicurrency_code_already_added'); return -1; } - if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + if (empty($this->entity) || $this->entity <= 0) { + $this->entity = $conf->entity; + } $now = date('Y-m-d H:i:s'); // Insert request @@ -163,7 +164,9 @@ class MultiCurrency extends CommonObject if ($trigger) { $result = $this->call_trigger('CURRENCY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } } @@ -194,8 +197,11 @@ class MultiCurrency extends CommonObject $sql = 'SELECT'; $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS c'; - if (!empty($code)) $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity; - else $sql .= ' WHERE c.rowid = '.$id; + if (!empty($code)) { + $sql .= ' WHERE c.code = \''.$this->db->escape($code).'\' AND c.entity = '.$conf->entity; + } else { + $sql .= ' WHERE c.rowid = '.$id; + } dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -308,7 +314,9 @@ class MultiCurrency extends CommonObject if (!$error && $trigger) { $result = $this->call_trigger('CURRENCY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Commit or rollback @@ -341,7 +349,9 @@ class MultiCurrency extends CommonObject if ($trigger) { $result = $this->call_trigger('CURRENCY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { @@ -383,10 +393,8 @@ class MultiCurrency extends CommonObject */ public function deleteRates() { - foreach ($this->rates as &$rate) - { - if ($rate->delete() <= 0) - { + foreach ($this->rates as &$rate) { + if ($rate->delete() <= 0) { return false; } } @@ -402,11 +410,10 @@ class MultiCurrency extends CommonObject */ public function addRate($rate) { - $currencyRate = new CurrencyRate($this->db); + $currencyRate = new CurrencyRate($this->db); $currencyRate->rate = price2num($rate); - if ($currencyRate->create($this->id) > 0) - { + if ($currencyRate->create($this->id) > 0) { $this->rate = $currencyRate; return 1; } else { @@ -433,19 +440,20 @@ class MultiCurrency extends CommonObject $sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'"; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && ($line = $db->fetch_object($resql))) - { + if ($resql && ($line = $db->fetch_object($resql))) { $currency->name = $line->label; } - if ($currency->create($user) > 0) - { + if ($currency->create($user) > 0) { $currency->addRate($rate); - if (!empty($line)) return 2; - else return 1; + if (!empty($line)) { + return 2; + } else { + return 1; + } } return -1; @@ -469,7 +477,7 @@ class MultiCurrency extends CommonObject */ public function getRate() { - $sql = 'SELECT cr.rowid'; + $sql = 'SELECT cr.rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; $sql .= ' WHERE cr.fk_multicurrency = '.$this->id; $sql .= ' AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM '.MAIN_DB_PREFIX.$this->table_element_line.' AS cr2 WHERE cr2.fk_multicurrency = '.$this->id.')'; @@ -492,14 +500,17 @@ class MultiCurrency extends CommonObject */ public static function getIdFromCode($db, $code) { - global $conf; + global $conf; - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid; - else return 0; + if ($resql && $obj = $db->fetch_object($resql)) { + return $obj->rowid; + } else { + return 0; + } } /** @@ -516,7 +527,7 @@ class MultiCurrency extends CommonObject { global $conf; - $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; + $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql1 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; $sql1 .= " WHERE m.code = '".$db->escape($code)."'"; @@ -531,12 +542,14 @@ class MultiCurrency extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql1.$sql2.$sql3); - if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); - else { - if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) - { + if ($resql && $obj = $db->fetch_object($resql)) { + return array($obj->rowid, $obj->rate); + } else { + if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) { $resql = $db->query($sql1.$sql3); - if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); + if ($resql && $obj = $db->fetch_object($resql)) { + return array($obj->rowid, $obj->rate); + } } return array(0, 1); @@ -556,11 +569,15 @@ class MultiCurrency extends CommonObject { $multicurrency_tx = self::getInvoiceRate($fk_facture, $table); - if ($multicurrency_tx) - { - if ($way == 'dolibarr') return price2num($amount * $multicurrency_tx, 'MU'); - else return price2num($amount / $multicurrency_tx, 'MU'); - } else return $amount; + if ($multicurrency_tx) { + if ($way == 'dolibarr') { + return price2num($amount * $multicurrency_tx, 'MU'); + } else { + return price2num($amount / $multicurrency_tx, 'MU'); + } + } else { + return $amount; + } } /** @@ -578,8 +595,7 @@ class MultiCurrency extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); - if ($resql && ($line = $db->fetch_object($resql))) - { + if ($resql && ($line = $db->fetch_object($resql))) { return $line->multicurrency_tx; } @@ -597,14 +613,11 @@ class MultiCurrency extends CommonObject { global $conf; - if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE) - { + if ($conf->currency != $conf->global->MULTICURRENCY_APP_SOURCE) { $alternate_source = 'USD'.$conf->currency; - if (!empty($TRate->{$alternate_source})) - { + if (!empty($TRate->{$alternate_source})) { $coef = $TRate->USDUSD / $TRate->{$alternate_source}; - foreach ($TRate as $attr => &$rate) - { + foreach ($TRate as $attr => &$rate) { $rate *= $coef; } @@ -642,22 +655,17 @@ class MultiCurrency extends CommonObject $response = $resget['content']; $response = json_decode($response); - if ($response->success) - { + if ($response->success) { $TRate = $response->quotes; $timestamp = $response->timestamp; - if (self::recalculRates($TRate) >= 0) - { - foreach ($TRate as $currency_code => $rate) - { + if (self::recalculRates($TRate) >= 0) { + foreach ($TRate as $currency_code => $rate) { $code = substr($currency_code, 3, 3); $obj = new MultiCurrency($db); - if ($obj->fetch(null, $code) > 0) - { + if ($obj->fetch(null, $code) > 0) { $obj->updateRate($rate); - } elseif ($addifnotfound) - { + } elseif ($addifnotfound) { self::addRateFromDolibarr($code, $rate); } } @@ -681,11 +689,14 @@ class MultiCurrency extends CommonObject */ public static function checkCodeAlreadyExists($code) { - global $db; + global $db; - $currency = new MultiCurrency($db); - if ($currency->fetch('', $code) > 0) return true; - else return false; + $currency = new MultiCurrency($db); + if ($currency->fetch('', $code) > 0) { + return true; + } else { + return false; + } } } @@ -758,7 +769,9 @@ class CurrencyRate extends CommonObjectLine $error = 0; $this->rate = price2num($this->rate); - if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + if (empty($this->entity) || $this->entity <= 0) { + $this->entity = $conf->entity; + } $now = empty($this->date_sync) ? dol_now() : $this->date_sync; // Insert request @@ -791,7 +804,9 @@ class CurrencyRate extends CommonObjectLine if ($trigger) { $result = $this->call_trigger('CURRENCYRATE_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } } @@ -867,8 +882,12 @@ class CurrencyRate extends CommonObjectLine // Update request $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= ' rate='.$this->rate; - if (!empty($this->date_sync)) $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; - if (!empty($this->fk_multicurrency)) $sql .= ', fk_multicurrency='.$this->fk_multicurrency; + if (!empty($this->date_sync)) { + $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; + } + if (!empty($this->fk_multicurrency)) { + $sql .= ', fk_multicurrency='.$this->fk_multicurrency; + } $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); @@ -883,7 +902,9 @@ class CurrencyRate extends CommonObjectLine if (!$error && $trigger) { $result = $this->call_trigger('CURRENCYRATE_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } // Commit or rollback @@ -916,7 +937,9 @@ class CurrencyRate extends CommonObjectLine if ($trigger) { $result = $this->call_trigger('CURRENCYRATE_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } } if (!$error) { diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index eae788b0587..da7921fa7fe 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -58,12 +58,18 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "cr.date_sync"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "cr.date_sync"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -74,7 +80,9 @@ $form = new Form($db); $hookmanager->initHooks(array('EditorRatelist', 'globallist')); -if (empty($action)) $action = 'list'; +if (empty($action)) { + $action = 'list'; +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -184,20 +192,24 @@ if ($action == "confirm_delete") { } -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $sall = ""; $search_date_sync = ""; $search_rate = ""; @@ -324,10 +336,18 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); -if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); -if ($search_code) $sql .= natural_search('m.code', $search_code); +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_date_sync) { + $sql .= natural_search('cr.date_sync', $search_date_sync); +} +if ($search_rate) { + $sql .= natural_search('cr.rate', $search_rate); +} +if ($search_code) { + $sql .= natural_search('m.code', $search_code); +} $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; // Add where from hooks @@ -345,14 +365,12 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); if ($result) { $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -364,29 +382,46 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($sall) $param .= "&sall=".urlencode($sall); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= "&sall=".urlencode($sall); + } - if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); - if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param .= "&search_code=".urlencode($search_code); + if ($search_date_sync) { + $param = "&search_date_sync=".urlencode($search_date_sync); + } + if ($search_rate) { + $param = "&search_rate=".urlencode($search_rate); + } + if ($search_code != '') { + $param .= "&search_code=".urlencode($search_code); + } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - if ($user->admin) $arrayofmassactions['predelete'] = $langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($user->admin) { + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -399,9 +434,10 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($sall) - { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } @@ -411,11 +447,13 @@ if ($resql) $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } - if ($moreforfilter) - { + if ($moreforfilter) { print '
'; print $moreforfilter; print '
'; @@ -423,7 +461,9 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + } print '
'; print '
'.$langs->trans("WidgetFile").' : '.$pathtofile.''; @@ -3335,29 +3336,28 @@ if ($module == 'initmodule') } } - if ($tab == 'cli') - { + if ($tab == 'cli') { $clifiles = array(); $i = 0; $dircli = array('/'.strtolower($module).'/scripts'); - foreach ($dircli as $reldir) - { + foreach ($dircli as $reldir) { $dir = dol_buildpath($reldir, 0); $newdir = dol_osencode($dir); // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) - if (!is_dir($newdir)) continue; + if (!is_dir($newdir)) { + continue; + } $handle = opendir($newdir); - if (is_resource($handle)) - { - while (($tmpfile = readdir($handle)) !== false) - { - if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) - { - if (preg_match('/\.back$/', $tmpfile)) continue; + if (is_resource($handle)) { + while (($tmpfile = readdir($handle)) !== false) { + if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) { + if (preg_match('/\.back$/', $tmpfile)) { + continue; + } $clifiles[$i]['relpath'] = preg_replace('/^\//', '', $reldir).'/'.$tmpfile; @@ -3368,16 +3368,13 @@ if ($module == 'initmodule') } } - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("CLIDesc").'
'; print '
'; print ''; - if (!empty($clifiles)) - { - foreach ($clifiles as $clifile) - { + if (!empty($clifiles)) { + foreach ($clifiles as $clifile) { $pathtofile = $clifile['relpath']; print '\n"; - if (count($cronjobs)) - { - foreach ($cronjobs as $cron) - { + if (count($cronjobs)) { + foreach ($cronjobs as $cron) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -3534,23 +3535,21 @@ if ($module == 'initmodule') } } - if ($tab == 'specifications') - { + if ($tab == 'specifications') { $specs = dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''.$langs->trans("SpecDefDesc").'
'; print '
'; print '
'.$langs->trans("CLIFile").' : '.$pathtofile.''; @@ -3417,14 +3414,12 @@ if ($module == 'initmodule') } } - if ($tab == 'cron') - { + if ($tab == 'cron') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; $cronjobs = $moduleobj->cronjobs; - if ($action != 'editfile' || empty($file)) - { + if ($action != 'editfile' || empty($file)) { print ''.str_replace('{s1}', ''.$langs->transnoentities('CronList').'', $langs->trans("CronJobDefDesc", '{s1}')).'
'; print '
'; @@ -3453,10 +3448,8 @@ if ($module == 'initmodule') print_liste_field_titre("Comment", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); print "
'; @@ -3464,8 +3457,7 @@ if ($module == 'initmodule') print ''; - if ($cron['jobtype'] == 'method') - { + if ($cron['jobtype'] == 'method') { $text = $langs->trans("CronClass"); $texttoshow = $langs->trans('CronModule').': '.$module.'
'; $texttoshow .= $langs->trans('CronClass').': '.$cron['class'].'
'; @@ -3473,8 +3465,7 @@ if ($module == 'initmodule') $texttoshow .= $langs->trans('CronMethod').': '.$cron['method']; $texttoshow .= '
'.$langs->trans('CronArgs').': '.$cron['parameters']; $texttoshow .= '
'.$langs->trans('Comment').': '.$langs->trans($cron['comment']); - } elseif ($cron['jobtype'] == 'command') - { + } elseif ($cron['jobtype'] == 'command') { $text = $langs->trans('CronCommand'); $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($cron['command']); $texttoshow .= '
'.$langs->trans('CronArgs').': '.$cron['parameters']; @@ -3484,10 +3475,18 @@ if ($module == 'initmodule') print '
'; - if ($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if ($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if ($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if ($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + if ($cron['unitfrequency'] == "60") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); + } + if ($cron['unitfrequency'] == "3600") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); + } + if ($cron['unitfrequency'] == "86400") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); + } + if ($cron['unitfrequency'] == "604800") { + print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + } print ''; @@ -3495,7 +3494,9 @@ if ($module == 'initmodule') print ''; - if (!empty($cron['comment'])) {print $cron['comment']; } + if (!empty($cron['comment'])) { + print $cron['comment']; + } print '
'; - if (is_array($specs) && !empty($specs)) - { - foreach ($specs as $spec) - { + if (is_array($specs) && !empty($specs)) { + foreach ($specs as $spec) { $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; $format = 'asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; + if (preg_match('/\.md$/i', $spec['name'])) { + $format = 'markdown'; + } print ''; @@ -3604,8 +3603,9 @@ if ($module == 'initmodule') // HTML print ' '.$langs->trans("PathToModuleDocumentation", "HTML").' : '; - if (!dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; - else { + if (!dol_is_file($outputfiledoc)) { + print ''.$langs->trans("FileNotYetGenerated").''; + } else { print ''; print ''; print $outputfiledoc; @@ -3617,8 +3617,9 @@ if ($module == 'initmodule') // PDF print ' '.$langs->trans("PathToModuleDocumentation", "PDF").' : '; - if (!dol_is_file($outputfiledocpdf)) print ''.$langs->trans("FileNotYetGenerated").''; - else { + if (!dol_is_file($outputfiledocpdf)) { + print ''.$langs->trans("FileNotYetGenerated").''; + } else { print ''; print ''; print $outputfiledocpdf; @@ -3636,18 +3637,18 @@ if ($module == 'initmodule') print ''; print ''; print ''; print ''; } - if ($tab == 'buildpackage') - { + if ($tab == 'buildpackage') { print ''.$langs->trans("BuildPackageDesc").''; print '
'; - if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP')) - { + if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP')) { print img_warning().' '.$langs->trans("ErrNoZipEngine"); print '
'; } @@ -3662,8 +3663,7 @@ if ($module == 'initmodule') dol_include_once($pathtofile); $class = 'mod'.$module; - if (class_exists($class)) - { + if (class_exists($class)) { try { $moduleobj = new $class($db); } catch (Exception $e) { @@ -3678,8 +3678,7 @@ if ($module == 'initmodule') } $arrayversion = explode('.', $moduleobj->version, 3); - if (count($arrayversion)) - { + if (count($arrayversion)) { $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; } @@ -3687,8 +3686,9 @@ if ($module == 'initmodule') print '
'; print ' '.$langs->trans("PathToModulePackage").' : '; - if (!dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; - else { + if (!dol_is_file($outputfilezip)) { + print ''.$langs->trans("FileNotYetGenerated").''; + } else { $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; print '
'.$outputfilezip.''; print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; @@ -3706,8 +3706,7 @@ if ($module == 'initmodule') print ''; } - if ($tab != 'description') - { + if ($tab != 'description') { print dol_get_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index d527f1978a9..30cc93a6d51 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -25,16 +25,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} // Libraries require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/modulebuilder/template/admin/myobject_extrafields.php b/htdocs/modulebuilder/template/admin/myobject_extrafields.php index 41ca86a0ce2..cd2125547e8 100644 --- a/htdocs/modulebuilder/template/admin/myobject_extrafields.php +++ b/htdocs/modulebuilder/template/admin/myobject_extrafields.php @@ -29,16 +29,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/mymodule.lib.php'; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 93bbc8a6612..06b169863f5 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -25,16 +25,30 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} global $langs, $user; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 13a2b8e895c..8559411a3d4 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -99,8 +99,7 @@ class ActionsMyModule $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' // Do what you want here... // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. } @@ -132,10 +131,8 @@ class ActionsMyModule $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - foreach ($parameters['toselect'] as $objectid) - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } } @@ -168,8 +165,7 @@ class ActionsMyModule $disabled = 1; /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' $this->resprints = ''; } @@ -204,8 +200,7 @@ class ActionsMyModule dol_syslog(get_class($this).'::executeHooks action='.$action); /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' } return $ret; diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 2e04e34dcac..da616de0d82 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -119,29 +119,42 @@ class MyModuleApi extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } $sql = "SELECT t.rowid"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } $sql .= " WHERE 1 = 1"; // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($restrictonsocid && $socid) $sql .= " AND t.fk_soc = ".$socid; - if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".$socid; + } + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } // Insert sale filter if ($restrictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } - if ($sqlfilters) - { + if ($sqlfilters) { if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } @@ -161,11 +174,9 @@ class MyModuleApi extends DolibarrApi $result = $this->db->query($sql); $i = 0; - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); $tmp_object = new MyObject($this->db); if ($tmp_object->fetch($obj->rowid)) { @@ -236,12 +247,13 @@ class MyModuleApi extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $this->myobject->$field = $value; } - if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) - { + if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); } else { throw new RestException(500, $this->myobject->error); @@ -272,8 +284,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->myobject->delete(DolibarrApiAccess::$user)) - { + if (!$this->myobject->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error); } @@ -338,8 +349,7 @@ class MyModuleApi extends DolibarrApi // If object has lines, remove $db property if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) - { + for ($i = 0; $i < $nboflines; $i++) { $this->_cleanObjectDatas($object->lines[$i]); unset($object->lines[$i]->lines); @@ -362,9 +372,12 @@ class MyModuleApi extends DolibarrApi { $myobject = array(); foreach ($this->myobject->fields as $field => $propfield) { - if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field - if (!isset($data[$field])) + if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) { + continue; // Not a mandatory field + } + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $myobject[$field] = $data[$field]; } return $myobject; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e07e7757751..2b17b0f84f8 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -232,8 +232,12 @@ class MyObject extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } // Example to show how to set values of fields definition dynamically /*if ($user->rights->mymodule->myobject->read) { @@ -242,23 +246,17 @@ class MyObject extends CommonObject }*/ // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -298,7 +296,9 @@ class MyObject extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } // get lines so they will be clone //foreach($this->lines as $line) @@ -310,21 +310,28 @@ class MyObject extends CommonObject unset($object->import_key); // Clear fields - if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; - if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; - if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; } - if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); } - if (property_exists($object, 'date_modification')) { $object->date_modification = null; } + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -340,22 +347,19 @@ class MyObject extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { - if ($this->copy_linked_contact($object, 'external') < 0) + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { $error++; + } } } @@ -381,7 +385,9 @@ class MyObject extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -421,8 +427,11 @@ class MyObject extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -455,8 +464,7 @@ class MyObject extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) - { + while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -512,8 +520,7 @@ class MyObject extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -538,8 +545,7 @@ class MyObject extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -557,8 +563,7 @@ class MyObject extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $num = $this->getNextNumRef(); } else { $num = $this->ref; @@ -570,57 +575,58 @@ class MyObject extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " status = ".self::STATUS_VALIDATED; - if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; - if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MYOBJECT_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'myobject/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'myobject/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->mymodule->dir_output.'/myobject/'.$oldref; $dirdest = $conf->mymodule->dir_output.'/myobject/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->mymodule->dir_output.'/myobject/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -633,14 +639,12 @@ class MyObject extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -660,8 +664,7 @@ class MyObject extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->status <= self::STATUS_DRAFT) - { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -685,8 +688,7 @@ class MyObject extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_VALIDATED) - { + if ($this->status != self::STATUS_VALIDATED) { return 0; } @@ -710,8 +712,7 @@ class MyObject extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_CANCELED) { return 0; } @@ -739,7 +740,9 @@ class MyObject extends CommonObject { global $conf, $langs, $hookmanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -752,25 +755,28 @@ class MyObject extends CommonObject $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } if ($option == 'nolink') { $linkstart = 'showphoto_on_popup)) { - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } } else { if ($withpicto) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -813,7 +821,9 @@ class MyObject extends CommonObject } } - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -822,8 +832,11 @@ class MyObject extends CommonObject $hookmanager->initHooks(array('myobjectdao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -850,8 +863,7 @@ class MyObject extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule@mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -864,7 +876,9 @@ class MyObject extends CommonObject $statusType = 'status'.$status; //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_CANCELED) $statusType = 'status6'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -882,28 +896,23 @@ class MyObject extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' WHERE t.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -943,8 +952,7 @@ class MyObject extends CommonObject $objectline = new MyObjectLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); - if (is_numeric($result)) - { + if (is_numeric($result)) { $this->error = $this->error; $this->errors = $this->errors; return $result; @@ -968,8 +976,7 @@ class MyObject extends CommonObject $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard'; } - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) - { + if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) { $mybool = false; $file = $conf->global->MYMODULE_MYOBJECT_ADDON.".php"; @@ -977,16 +984,14 @@ class MyObject extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/mymodule/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -995,8 +1000,7 @@ class MyObject extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($this); - if ($numref != '' && $numref != '-1') - { + if ($numref != '' && $numref != '-1') { return $numref; } else { $this->error = $obj->error; diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index cb6e15695c1..dc797b99a94 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -48,8 +48,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets global $conf; $this->db = $db; - if (is_array($conf->modules)) - { + if (is_array($conf->modules)) { $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0; } } @@ -73,8 +72,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $s .= $langs->trans("Status").': '; $s .= ''; @@ -112,24 +110,23 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $sql = " select rowid as id, email, firstname, lastname, plan, partner"; $sql .= " from ".MAIN_DB_PREFIX."myobject"; $sql .= " where email IS NOT NULL AND email != ''"; - if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; + if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') { + $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; + } $sql .= " ORDER BY email"; // Stocke destinataires dans target $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $i = 0; dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); $old = ''; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { + if ($old <> $obj->email) { $target[$j] = array( 'email' => $obj->email, 'name' => $obj->lastname, @@ -197,7 +194,9 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets { $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); - if ($a < 0) return -1; + if ($a < 0) { + return -1; + } return $a; } } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index d6cb191a405..3e389c1757f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -98,7 +98,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Recupere emetteur $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } @@ -129,8 +131,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texttitle = $langs->trans("ListOfDirectories"); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))); $listoffiles = array(); - foreach ($listofdir as $key=>$tmpdir) - { + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { @@ -140,7 +141,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); } else { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); + if (count($tmpfiles)) { + $listoffiles = array_merge($listoffiles, $tmpfiles); + } } } $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); @@ -159,8 +162,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Scan directories $nbofiles = count($listoffiles); - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) - { + if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) { $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; $texte .= count($listoffiles); @@ -168,11 +170,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= ''; } - if ($nbofiles) - { + if ($nbofiles) { $texte .= ''; @@ -208,37 +208,34 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; - if (empty($srctemplatepath)) - { + if (empty($srctemplatepath)) { dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); return -1; } // Add odtgeneration hook - if (!is_object($hookmanager)) - { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (!is_object($outputlangs)) $outputlangs = $langs; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->commande->dir_output) - { + if ($conf->commande->dir_output) { // If $object is id instead of object - if (!is_object($object)) - { + if (!is_object($object)) { $id = $object; $object = new Commande($this->db); $result = $object->fetch($id); - if ($result < 0) - { + if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } @@ -246,20 +243,19 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $dir = $conf->commande->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + if (!preg_match('/specimen/i', $objectref)) { + $dir .= "/".$objectref; + } $file = $dir."/".$objectref.".odt"; - if (!file_exists($dir)) - { - if (dol_mkdir($dir) < 0) - { + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); @@ -269,10 +265,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) - { + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { $format = $conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format = '%Y%m%d%H%M%S'; + if ($format == '1') { + $format = '%Y%m%d%H%M%S'; + } $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { $filename = $newfiletmp.'.'.$newfileformat; @@ -289,16 +286,14 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // If CUSTOMER contact defined on order, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usecontact = true; $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name $contactobject = null; - if (!empty($usecontact)) - { + if (!empty($usecontact)) { if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $socobject = $object->contact; } else { @@ -326,8 +321,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; $paramfreetext = 'ORDER_FREE_TEXT'; - if (!empty($conf->global->$paramfreetext)) - { + if (!empty($conf->global->$paramfreetext)) { $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } @@ -343,8 +337,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject 'DELIMITER_RIGHT' => '}' ) ); - } catch (Exception $e) - { + } catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; @@ -359,8 +352,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Make substitutions into odt of freetext try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -374,7 +366,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) { + $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + } $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); @@ -383,19 +377,20 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach ($tmparray as $key=>$value) - { + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image - if (file_exists($value)) $odfHandler->setImage($key, $value); - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + if (file_exists($value)) { + $odfHandler->setImage($key, $value); + } else { + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } } else { // Text $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -404,32 +399,26 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $foundtagforlines = 1; try { $listlines = $odfHandler->setSegment('lines'); - } catch (OdfException $e) - { + } catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; dol_syslog($e->getMessage(), LOG_INFO); } - if ($foundtagforlines) - { + if ($foundtagforlines) { $linenumber = 0; - foreach ($object->lines as $line) - { + foreach ($object->lines as $line) { $linenumber++; $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) - { + } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -437,8 +426,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } $odfHandler->mergeSegment($listlines); } - } catch (OdfException $e) - { + } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; @@ -446,12 +434,10 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Replace labels translated $tmparray = $outputlangs->get_translations_for_substitutions(); - foreach ($tmparray as $key=>$value) - { + foreach ($tmparray as $key => $value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); - } catch (OdfException $e) - { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -483,8 +469,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 4546d7044bd..3d900bc06e7 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -163,7 +163,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // Get source company $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff @@ -201,9 +203,13 @@ class pdf_standard_myobject extends ModelePDFMyObject dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); - if (!is_object($outputlangs)) $outputlangs = $langs; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) { + $outputlangs->charset_output = 'ISO-8859-1'; + } // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); @@ -226,67 +232,65 @@ class pdf_standard_myobject extends ModelePDFMyObject $realpatharray = array(); $this->atleastonephoto = false; /* - if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) - { - $objphoto = new Product($this->db); + if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) + { + $objphoto = new Product($this->db); - for ($i = 0; $i < $nblines; $i++) - { - if (empty($object->lines[$i]->fk_product)) continue; + for ($i = 0; $i < $nblines; $i++) + { + if (empty($object->lines[$i]->fk_product)) continue; - $objphoto->fetch($object->lines[$i]->fk_product); - //var_dump($objphoto->ref);exit; - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; - } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative - } + $objphoto->fetch($object->lines[$i]->fk_product); + //var_dump($objphoto->ref);exit; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + } else { + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative + } - $arephoto = false; - foreach ($pdir as $midir) - { - if (!$arephoto) - { - $dir = $conf->product->dir_output.'/'.$midir; + $arephoto = false; + foreach ($pdir as $midir) + { + if (!$arephoto) + { + $dir = $conf->product->dir_output.'/'.$midir; - foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) - { - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo - { - if ($obj['photo_vignette']) - { - $filename = $obj['photo_vignette']; - } else { - $filename = $obj['photo']; - } - } else { - $filename = $obj['photo']; - } + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) + { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + { + if ($obj['photo_vignette']) + { + $filename = $obj['photo_vignette']; + } else { + $filename = $obj['photo']; + } + } else { + $filename = $obj['photo']; + } - $realpath = $dir.$filename; - $arephoto = true; - $this->atleastonephoto = true; - } - } - } + $realpath = $dir.$filename; + $arephoto = true; + $this->atleastonephoto = true; + } + } + } - if ($realpath && $arephoto) $realpatharray[$i] = $realpath; - } - } + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; + } + } */ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->mymodule->dir_output.'/myobject') - { + if ($conf->mymodule->dir_output.'/myobject') { $object->fetch_thirdparty(); // Definition of $dir and $file - if ($object->specimen) - { + if ($object->specimen) { $dir = $conf->mymodule->dir_output.'/myobject'; $file = $dir."/SPECIMEN.pdf"; } else { @@ -294,20 +298,16 @@ class pdf_standard_myobject extends ModelePDFMyObject $dir = $conf->mymodule->dir_output.'/myobject/'.$objectref; $file = $dir."/".$objectref.".pdf"; } - if (!file_exists($dir)) - { - if (dol_mkdir($dir) < 0) - { + if (!file_exists($dir)) { + if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } - if (file_exists($dir)) - { + if (file_exists($dir)) { // Add pdfgeneration hook - if (!is_object($hookmanager)) - { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } @@ -328,16 +328,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) - if (class_exists('TCPDF')) - { + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) - { + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } @@ -351,7 +349,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { + $pdf->SetCompression(false); + } // Set certificate $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT; @@ -374,7 +374,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // New page $pdf->AddPage(); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); @@ -386,7 +388,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_height = 130 - $top_shift; $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $tab_height_newpage -= $top_shift; + } $nexY = $tab_top - 1; @@ -394,14 +398,12 @@ class pdf_standard_myobject extends ModelePDFMyObject $notetoshow = empty($object->note_public) ? '' : $object->note_public; // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) - { + if (!empty($extranote)) { $notetoshow = dol_concatdesc($notetoshow, $extranote); } $pagenb = $pdf->getPage(); - if ($notetoshow) - { + if ($notetoshow) { $tab_top -= 2; $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; @@ -420,16 +422,19 @@ class pdf_standard_myobject extends ModelePDFMyObject $pageposafternote = $pdf->getPage(); $posyafter = $pdf->GetY(); - if ($pageposafternote > $pageposbeforenote) - { + if ($pageposafternote > $pageposbeforenote) { $pdf->rollbackTransaction(true); // prepare pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); // The only function to edit the bottom margin of current page to set it. @@ -445,8 +450,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; @@ -483,8 +487,12 @@ class pdf_standard_myobject extends ModelePDFMyObject // apply note frame to last page $pdf->setPage($pageposafternote); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); } else // No pagebreak @@ -495,15 +503,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // not enough space, need to add page $pdf->AddPage('', '', true); $pagenb++; $pageposafternote++; $pdf->setPage($pageposafternote); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } $posyafter = $tab_top_newpage; } @@ -528,15 +539,16 @@ class pdf_standard_myobject extends ModelePDFMyObject // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - for ($i = 0; $i < $nblines; $i++) - { + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it $imglinesize = array(); - if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + if (!empty($realpatharray[$i])) { + $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. @@ -545,25 +557,26 @@ class pdf_standard_myobject extends ModelePDFMyObject $showpricebeforepagebreak = 1; $posYAfterImage = 0; - if ($this->getColumnStatus('photo')) - { + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page - { + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page $pdf->AddPage('', '', true); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { $showpricebeforepagebreak = 1; - else $showpricebeforepagebreak = 0; + } else { + $showpricebeforepagebreak = 0; + } } - if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) - { + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; @@ -571,15 +584,13 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Description of product line - if ($this->getColumnStatus('desc')) - { + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); - if ($pageposafter > $pageposbefore) // There is a pagebreak - { + if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. @@ -588,20 +599,22 @@ class pdf_standard_myobject extends ModelePDFMyObject $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text - { - if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page - { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pdf->setPage($pageposafter + 1); } } else { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { $showpricebeforepagebreak = 1; - else $showpricebeforepagebreak = 0; + } else { + $showpricebeforepagebreak = 0; + } } } else // No pagebreak { @@ -624,8 +637,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Quantity // Enough for 6 chars - if ($this->getColumnStatus('qty')) - { + if ($this->getColumnStatus('qty')) { $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $this->printStdColumnContent($pdf, $curY, 'qty', $qty); $nexY = max($pdf->GetY(), $nexY); @@ -634,8 +646,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Extrafields if (!empty($object->lines[$i]->array_options)) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { - if ($this->getColumnStatus($extrafieldColKey)) - { + if ($this->getColumnStatus($extrafieldColKey)) { $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey); $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); $nexY = max($pdf->GetY(), $nexY); @@ -659,13 +670,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $sign = 1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); - if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation - { - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; - else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) { + $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + } else { + $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + } } else { - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva; - else $tvaligne = $sign * $object->lines[$i]->total_tva; + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) { + $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva; + } else { + $tvaligne = $sign * $object->lines[$i]->total_tva; + } } $localtax1ligne = $object->lines[$i]->total_localtax1; @@ -675,16 +691,21 @@ class pdf_standard_myobject extends ModelePDFMyObject $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; - if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; - if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; + if ($object->remise_percent) { + $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + } + if ($object->remise_percent) { + $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + } + if ($object->remise_percent) { + $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; + } $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined - && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax - { + && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : ''; $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : ''; @@ -698,8 +719,12 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; - if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { + $vatrate .= '*'; + } + if (!isset($this->tva[$vatrate])) { + $this->tva[$vatrate] = 0; + } $this->tva[$vatrate] += $tvaligne; $nexY = max($nexY, $posYAfterImage); @@ -725,7 +750,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { @@ -737,15 +764,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + $this->_pagehead($pdf, $object, 0, $outputlangs); + } } } // Show square - if ($pagenb == $pageposbeforeprintlines) - { + if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { @@ -761,15 +791,17 @@ class pdf_standard_myobject extends ModelePDFMyObject // Display payment area /* - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) - { - $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); - } - */ + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) + { + $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); + } + */ // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); + if (method_exists($pdf, 'AliasNbPages')) { + $pdf->AliasNbPages(); + } $pdf->Close(); @@ -780,14 +812,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) - { + if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); + } $this->result = array('fullpath'=>$file); @@ -837,7 +869,9 @@ class pdf_standard_myobject extends ModelePDFMyObject // Force to disable hidetop and hidebottom $hidebottom = 0; - if ($hidetop) $hidetop = -1; + if ($hidetop) { + $hidetop = -1; + } $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -846,8 +880,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - if (empty($hidetop)) - { + if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); @@ -899,8 +932,7 @@ class pdf_standard_myobject extends ModelePDFMyObject pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) - { + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); } @@ -915,20 +947,18 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) - { - if ($this->emetteur->logo) - { + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { + if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) - { + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; } - if (is_readable($logo)) - { + if (is_readable($logo)) { $height = pdf_getHeightForLogo($logo); $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -959,8 +989,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref); - if ($object->statut == $object::STATUS_DRAFT) - { + if ($object->statut == $object::STATUS_DRAFT) { $pdf->SetTextColor(128, 0, 0); $textref .= ' - '.$outputlangs->transnoentities("NotValidated"); } @@ -969,19 +998,16 @@ class pdf_standard_myobject extends ModelePDFMyObject $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); - if ($object->ref_client) - { + if ($object->ref_client) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) - { + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); - if (!empty($object->project->ref)) - { + if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -989,11 +1015,9 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) - { + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (!empty($object->project->ref)) - { + if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -1011,8 +1035,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); - if ($object->thirdparty->code_client) - { + if ($object->thirdparty->code_client) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); @@ -1020,11 +1043,9 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) - { + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); $posy += 4; @@ -1040,13 +1061,11 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show list of linked objects $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) - { + if ($current_y < $pdf->getY()) { $top_shift = $pdf->getY() - $current_y; } - if ($showaddress) - { + if ($showaddress) { // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); @@ -1054,7 +1073,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posy += $top_shift; $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->page_largeur - $this->marge_droite - 80; + } $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; @@ -1084,8 +1105,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // If BILLING contact defined on invoice, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'BILLING'); - if (count($arrayidcontact) > 0) - { + if (count($arrayidcontact) > 0) { $usecontact = true; $result = $object->fetch_contact($arrayidcontact[0]); } @@ -1105,11 +1125,15 @@ class pdf_standard_myobject extends ModelePDFMyObject // Show recipient $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + if ($this->page_largeur < 210) { + $widthrecbox = 84; // To work with US executive format + } $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + $posx = $this->marge_gauche; + } // Show recipient frame $pdf->SetTextColor(0, 0, 0); @@ -1179,22 +1203,22 @@ class pdf_standard_myobject extends ModelePDFMyObject ); /* - * For exemple - $this->cols['theColKey'] = array( - 'rank' => $rank, // int : use for ordering columns - 'width' => 20, // the column width in mm - 'title' => array( - 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - 'label' => ' ', // the final label : used fore final generated text - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'content' => array( - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - */ + * For exemple + $this->cols['theColKey'] = array( + 'rank' => $rank, // int : use for ordering columns + 'width' => 20, // the column width in mm + 'title' => array( + 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + 'label' => ' ', // the final label : used fore final generated text + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + */ $rank = 0; // do not use negative rank $this->cols['desc'] = array( @@ -1230,8 +1254,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) - { + if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1247,8 +1270,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) - { + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $this->cols['vat']['status'] = true; } @@ -1285,8 +1307,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if ($this->situationinvoice) - { + if ($this->situationinvoice) { $this->cols['progress']['status'] = true; } @@ -1344,11 +1365,9 @@ class pdf_standard_myobject extends ModelePDFMyObject ); $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook - if ($reshook < 0) - { + if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } elseif (empty($reshook)) - { + } elseif (empty($reshook)) { $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys } else { $this->cols = $hookmanager->resArray; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index ae5f5d1e876..9c685e65d9a 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -113,8 +113,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject /*$mysoc->code_client = $old_code_client; $mysoc->typent_code = $old_code_type;*/ - if (!$numExample) - { + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } return $numExample; @@ -135,8 +134,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject // We get cursor rule $mask = $conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; - if (!$mask) - { + if (!$mask) { $this->error = 'NotConfigured'; return 0; } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index 6f1a5da7dd3..75068cf8d57 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -96,13 +96,13 @@ class mod_myobject_standard extends ModeleNumRefMyObject } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + if ($row) { + $coyymm = substr($row[0], 0, 6); $max = $row[0]; + } } - if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) - { + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; @@ -133,11 +133,13 @@ class mod_myobject_standard extends ModeleNumRefMyObject } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = intval($obj->max); - else $max = 0; + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } else { dol_syslog("mod_myobject_standard::getNextValue", LOG_DEBUG); return -1; @@ -147,8 +149,11 @@ class mod_myobject_standard extends ModeleNumRefMyObject $date = $object->date_creation; $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max + 1); + if ($max >= (pow(10, 4) - 1)) { + $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + } else { + $num = sprintf("%04s", $max + 1); + } dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php index 78711e33a4d..8f0d86e3823 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/modules_myobject.php @@ -141,10 +141,18 @@ abstract class ModeleNumRefMyObject global $langs; $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + if ($this->version == 'development') { + return $langs->trans("VersionDevelopment"); + } + if ($this->version == 'experimental') { + return $langs->trans("VersionExperimental"); + } + if ($this->version == 'dolibarr') { + return DOL_VERSION; + } + if ($this->version) { + return $this->version; + } return $langs->trans("NotAvailable"); } } diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php index 06e3498fca0..67aac8c0e98 100644 --- a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php @@ -16,8 +16,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -36,12 +35,13 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("mymodule"); $total = 0; $ilink = 0; -foreach ($linkedObjectBlock as $key => $objectlink) -{ +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } ?>
diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 8c0f39927bd..94365ae2c61 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -92,7 +92,9 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->mymodule->enabled)) return 0; // If module is not enabled, we do nothing + if (empty($conf->mymodule->enabled)) { + return 0; // If module is not enabled, we do nothing + } // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index ecffe5dcf97..985cbe6aa18 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -23,14 +23,26 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled. Language code is found on url. -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); // File must be accessed by logon page so without login +} //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} session_cache_limiter('public'); // false or '' = keep cache instruction added by server @@ -40,16 +52,30 @@ session_cache_limiter('public'); // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index fea88d695ec..fe04cdc2ad9 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -17,16 +17,36 @@ * Library javascript to enable Browser notifications */ -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); -if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIREUSER')) { + define('NOREQUIREUSER', '1'); +} +if (!defined('NOREQUIREDB')) { + define('NOREQUIREDB', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOREQUIRETRAN')) { + define('NOREQUIRETRAN', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} /** @@ -38,16 +58,30 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} // Define js type header('Content-Type: application/javascript'); diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index ebd5b837e3d..e3117d88303 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -41,14 +41,19 @@ function myobjectPrepareHead($object) $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) - { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; - if (!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) { + $nbNote++; + } + if (!empty($object->note_public)) { + $nbNote++; + } $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + if ($nbNote > 0) { + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + } $head[$h][2] = 'note'; $h++; } @@ -60,7 +65,9 @@ function myobjectPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + } $head[$h][2] = 'document'; $h++; diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index ee2fe6b28f0..2d262aeeb36 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -27,17 +27,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index fbd156f2a97..0bb3244ebdd 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 0a5e23cb07a..e99acc0b913 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -464,7 +480,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } if (empty($reshook)) { // Send diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 35e5be2716a..6d6345d9b99 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -25,17 +25,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index f1424906dd6..c0765394135 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 2cbccd1523b..ee8c2e6677e 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -132,7 +148,9 @@ foreach ($object->fields as $key => $val) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns @@ -161,7 +179,9 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; $permissiontodelete = $user->rights->mymodule->myobject->delete; // Security check -if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled'); +if (empty($conf->mymodule->enabled)) { + accessforbidden('Module not enabled'); +} $socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; @@ -260,14 +280,21 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} foreach ($search as $key => $val) { if (in_array($key, $object->fields)) { - if ($key == 'status' && $search[$key] == -1) continue; + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } if ($search[$key] != '') { @@ -330,7 +357,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if (!$resql) { @@ -550,7 +579,9 @@ print '
'."\n"; $needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -618,11 +649,15 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index abe8daf7622..0868cd3918d 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -46,17 +46,33 @@ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} // Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; -if (!$res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 0b8d7abfdfe..0dab19d7ae6 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -46,13 +46,25 @@ define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to $res = 0; // Try master.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/master.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/master.inc.php"; -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php"; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/master.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/master.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/master.inc.php"; +} // Try master.inc.php using relative path -if (!$res && file_exists("../master.inc.php")) $res = @include "../master.inc.php"; -if (!$res && file_exists("../../master.inc.php")) $res = @include "../../master.inc.php"; -if (!$res && file_exists("../../../master.inc.php")) $res = @include "../../../master.inc.php"; +if (!$res && file_exists("../master.inc.php")) { + $res = @include "../master.inc.php"; +} +if (!$res && file_exists("../../master.inc.php")) { + $res = @include "../../master.inc.php"; +} +if (!$res && file_exists("../../../master.inc.php")) { + $res = @include "../../../master.inc.php"; +} if (!$res) { print "Include of master fails"; exit(-1); @@ -65,7 +77,9 @@ $langs->load("main"); // To load language file for default language // Load user and its permissions $result = $user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user. -if (!$result > 0) { dol_print_error('', $user->error); exit; } +if (!$result > 0) { + dol_print_error('', $user->error); exit; +} $user->getrights(); @@ -162,8 +176,7 @@ else // -------------------- END OF YOUR CODE -------------------- -if (!$error) -{ +if (!$error) { $db->commit(); print '--- end ok'."\n"; } else { diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php index adf4a8f4ee7..280a0c98cdd 100644 --- a/htdocs/mrp/ajax/ajax_bom.php +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -22,13 +22,25 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; @@ -43,12 +55,11 @@ $action = GETPOST('action', 'aZ09'); $object = new BOM($db); $result = $object->fetch($idbom); -if ($result > 0) -{ +if ($result > 0) { // We remove properties we don't need in answer unset($object->fields); unset($object->db); echo json_encode($object); } else { - echo 'Failed to load category with id='.$idbom; + echo 'Failed to load category with id='.$idbom; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 121909eb28a..c5529e54884 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -208,25 +208,24 @@ class Mo extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -305,7 +304,9 @@ class Mo extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } // get lines so they will be clone //foreach($this->lines as $line) @@ -322,14 +323,11 @@ class Mo extends CommonObject $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { + if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) - { + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } @@ -345,22 +343,19 @@ class Mo extends CommonObject $this->errors = $object->errors; } - if (!$error) - { + if (!$error) { // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) - { + if ($this->copy_linked_contact($object, 'internal') < 0) { $error++; } } - if (!$error) - { + if (!$error) { // copy external contacts if same company - if (property_exists($this, 'socid') && $this->socid == $object->socid) - { - if ($this->copy_linked_contact($object, 'external') < 0) + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { $error++; + } } } @@ -386,7 +381,9 @@ class Mo extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } return $result; } @@ -426,8 +423,11 @@ class Mo extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -458,8 +458,7 @@ class Mo extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($limit, $num)) - { + while ($i < min($limit, $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); @@ -496,8 +495,11 @@ class Mo extends CommonObject $sql .= $mostatic->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$mostatic->table_element.' as t'; $sql .= " WHERE t.role = '".$this->db->escape($role)."'"; - if ($lineid > 0) $sql .= ' AND t.fk_mrp_production = '.$lineid; - else $sql .= 'AND t.fk_mo = '.$this->id; + if ($lineid > 0) { + $sql .= ' AND t.fk_mrp_production = '.$lineid; + } else { + $sql .= 'AND t.fk_mo = '.$this->id; + } $resql = $this->db->query($sql); if ($resql) { @@ -618,8 +620,7 @@ class Mo extends CommonObject $this->db->begin(); // Insert lines in mrp_production table from BOM data - if (!$error) - { + if (!$error) { // TODO Check that production has not started. If yes, we stop here. $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'mrp_production WHERE fk_mo = '.$this->id; @@ -646,15 +647,15 @@ class Mo extends CommonObject include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; $bom = new Bom($this->db); $bom->fetch($this->fk_bom); - if ($bom->id > 0) - { + if ($bom->id > 0) { // Lines to consume if (!$error) { - foreach ($bom->lines as $line) - { + foreach ($bom->lines as $line) { $moline = new MoLine($this->db); $moline->fk_mo = $this->id; + $moline->origin_id = $line->id; + $moline->origin_type = 'bomline'; if ($line->qty_frozen) { $moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce } else { @@ -719,8 +720,7 @@ class Mo extends CommonObject */ public function deleteLine(User $user, $idline, $notrigger = false) { - if ($this->status < 0) - { + if ($this->status < 0) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; return -2; } @@ -741,8 +741,7 @@ class Mo extends CommonObject global $langs, $conf; $langs->load("mrp"); - if (!empty($conf->global->MRP_MO_ADDON)) - { + if (!empty($conf->global->MRP_MO_ADDON)) { $mybool = false; $file = $conf->global->MRP_MO_ADDON.".php"; @@ -750,16 +749,14 @@ class Mo extends CommonObject // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/mrp/"); // Load file with numbering class (if found) $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { + if ($mybool === false) { dol_print_error('', "Failed to include file ".$file); return ''; } @@ -767,8 +764,7 @@ class Mo extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($prod, $this); - if ($numref != "") - { + if ($numref != "") { return $numref; } else { $this->error = $obj->error; @@ -797,8 +793,7 @@ class Mo extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_VALIDATED) - { + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); return 0; } @@ -816,8 +811,7 @@ class Mo extends CommonObject $this->db->begin(); // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life $this->fetch_product(); $num = $this->getNextNumRef($this->product); } else { @@ -835,50 +829,47 @@ class Mo extends CommonObject dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($this->db); $this->error = $this->db->lasterror(); $error++; } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MRP_MO_VALIDATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { + if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'mrp/".$this->db->escape($this->newref)."'"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'mrp/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->mrp->dir_output.'/'.$oldref; $dirdest = $conf->mrp->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { + if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref $listoffiles = dol_dir_list($conf->mrp->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { + foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); $dirsource = $fileentry['path'].'/'.$dirsource; @@ -891,14 +882,12 @@ class Mo extends CommonObject } // Set new ref and current status - if (!$error) - { + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -917,8 +906,7 @@ class Mo extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->status <= self::STATUS_DRAFT) - { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -942,8 +930,7 @@ class Mo extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_VALIDATED && $this->status != self::STATUS_INPROGRESS) - { + if ($this->status != self::STATUS_VALIDATED && $this->status != self::STATUS_INPROGRESS) { return 0; } @@ -967,8 +954,7 @@ class Mo extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED) - { + if ($this->status != self::STATUS_PRODUCED && $this->status != self::STATUS_CANCELED) { return 0; } @@ -996,7 +982,9 @@ class Mo extends CommonObject { global $conf, $langs, $hookmanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -1008,35 +996,44 @@ class Mo extends CommonObject $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; - if ($option == 'production') $url = dol_buildpath('/mrp/mo_production.php', 1).'?id='.$this->id; + if ($option == 'production') { + $url = dol_buildpath('/mrp/mo_production.php', 1).'?id='.$this->id; + } - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMo"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -1044,8 +1041,11 @@ class Mo extends CommonObject $hookmanager->initHooks(array('modao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -1072,8 +1072,7 @@ class Mo extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelStatus)) - { + if (empty($this->labelStatus)) { global $langs; //$langs->load("mrp"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); @@ -1090,10 +1089,18 @@ class Mo extends CommonObject } $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_INPROGRESS) $statusType = 'status4'; - if ($status == self::STATUS_PRODUCED) $statusType = 'status6'; - if ($status == self::STATUS_CANCELED) $statusType = 'status9'; + if ($status == self::STATUS_VALIDATED) { + $statusType = 'status1'; + } + if ($status == self::STATUS_INPROGRESS) { + $statusType = 'status4'; + } + if ($status == self::STATUS_PRODUCED) { + $statusType = 'status6'; + } + if ($status == self::STATUS_CANCELED) { + $statusType = 'status9'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } @@ -1111,28 +1118,23 @@ class Mo extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' WHERE t.rowid = '.$id; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) - { + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -1172,8 +1174,7 @@ class Mo extends CommonObject $objectline = new MoLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); - if (is_numeric($result)) - { + if (is_numeric($result)) { $this->error = $this->error; $this->errors = $this->errors; return $result; @@ -1213,7 +1214,9 @@ class Mo extends CommonObject $modelpath = "core/modules/mrp/doc/"; - if (empty($modele)) return 1; // Remove this once a pdf_standard.php exists. + if (empty($modele)) { + return 1; // Remove this once a pdf_standard.php exists. + } return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } @@ -1273,10 +1276,8 @@ class Mo extends CommonObject print ''; $i = 0; - if (!empty($this->lines)) - { - foreach ($this->lines as $line) - { + if (!empty($this->lines)) { + foreach ($this->lines as $line) { /*if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) @@ -1317,8 +1318,7 @@ class Mo extends CommonObject $this->tpl['id'] = $line->id; $this->tpl['label'] = ''; - if (!empty($line->fk_product)) - { + if (!empty($line->fk_product)) { $productstatic = new Product($this->db); $productstatic->fetch($line->fk_product); $this->tpl['label'] .= $productstatic->getNomUrl(1); @@ -1386,6 +1386,8 @@ class MoLine extends CommonObjectLine public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'fk_mo' =>array('type'=>'integer', 'label'=>'Mo', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'origin_id' =>array('type'=>'integer', 'label'=>'Origin', 'enabled'=>1, 'visible'=>-1, 'notnull'=>0, 'position'=>17), + 'origin_type' =>array('type'=>'varchar(10)', 'label'=>'Origin type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>0, 'position'=>18), 'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_product' =>array('type'=>'integer', 'label'=>'Product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'fk_warehouse' =>array('type'=>'integer', 'label'=>'Warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>30), @@ -1405,6 +1407,8 @@ class MoLine extends CommonObjectLine public $rowid; public $fk_mo; + public $origin_id; + public $origin_type; public $position; public $fk_product; public $fk_warehouse; @@ -1432,27 +1436,25 @@ class MoLine extends CommonObjectLine $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -1487,7 +1489,6 @@ class MoLine extends CommonObjectLine public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -1513,8 +1514,11 @@ class MoLine extends CommonObjectLine $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -1545,8 +1549,7 @@ class MoLine extends CommonObjectLine if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < min($limit, $num)) - { + while ($i < min($limit, $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index b84a77c2288..f86a52f4aae 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -61,16 +61,14 @@ print '
'; * Statistics */ -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { $sql = "SELECT COUNT(t.rowid) as nb, status"; $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t"; $sql .= " GROUP BY t.status"; $sql .= " ORDER BY t.status ASC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -81,14 +79,12 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj) - { + if ($obj) { $vals[$obj->status] = $obj->nb; - $totalnb += $obj->nb; + $totalnb += $obj->nb; } $i++; } @@ -98,25 +94,32 @@ if ($conf->use_javascript_ajax) print '
'; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').'
trans("MyObject"); ?>
'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'; print ''."\n"; $listofstatus = array(0, 1, 2, 3, 9); - foreach ($listofstatus as $status) - { + foreach ($listofstatus as $status) { $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Mo::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Mo::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Mo::STATUS_INPROGRESS) $colorseries[$status] = $badgeStatus4; - if ($status == Mo::STATUS_PRODUCED) $colorseries[$status] = $badgeStatus6; - if ($status == Mo::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + if ($status == Mo::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Mo::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Mo::STATUS_INPROGRESS) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Mo::STATUS_PRODUCED) { + $colorseries[$status] = $badgeStatus6; + } + if ($status == Mo::STATUS_CANCELED) { + $colorseries[$status] = $badgeStatus9; + } - if (empty($conf->use_javascript_ajax)) - { + if (empty($conf->use_javascript_ajax)) { print ''; print ''; print ''; print "\n"; } } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print '
'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'
'.$staticmo->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -159,19 +162,16 @@ $sql .= $db->order("a.tms", "DESC"); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '
'; print ''; print ''; print ''; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $staticbom->id = $obj->rowid; @@ -210,19 +210,16 @@ $sql .= $db->order("a.tms", "DESC"); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { print '
'; print '
'.$langs->trans("LatestBOMModified", $max).'
'; print ''; print ''; $num = $db->num_rows($resql); - if ($num) - { + if ($num) { $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $staticmo->id = $obj->rowid; diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index a02bb0e8f84..8a5eef60211 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -21,13 +21,27 @@ * \brief File that include javascript functions used for dispatching qty/stock/lot */ -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} session_cache_limiter('public'); @@ -36,8 +50,11 @@ require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} ?> /** @@ -77,9 +94,9 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched >= qtyOrdered) { + window.alert("No remain qty to dispatch"); + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr var re1 = new RegExp('_'+index+'_1', 'g'); var re2 = new RegExp('-'+index+'-1', 'g'); diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index eb61c42e83d..62f74ce016e 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -59,14 +59,19 @@ function moPrepareHead($object) $head[$h][2] = 'stockmovement'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) - { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; - if (!empty($object->note_private)) $nbNote++; - if (!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) { + $nbNote++; + } + if (!empty($object->note_public)) { + $nbNote++; + } $head[$h][0] = dol_buildpath('/mrp/mo_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } $head[$h][2] = 'note'; $h++; } @@ -78,7 +83,9 @@ function moPrepareHead($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + } $head[$h][2] = 'document'; $h++; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 0fe9ba63e08..69c64b1a027 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -44,10 +44,11 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + if (!count($actioncode)) { + $actioncode = '0'; + } } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } @@ -57,12 +58,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = 'a.datep,a.id'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Initialize technical objects $object = new Mo($db); @@ -75,7 +82,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +if ($id > 0 || !empty($ref)) { + $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id; +} // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); @@ -90,20 +99,19 @@ $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'row $parameters = array('id'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -120,14 +128,15 @@ $contactstatic = new Contact($db); $form = new Form($db); $formproject = new FormProjets($db); -if ($object->id > 0) -{ +if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = ''; llxHeader('', $title, $help_url); - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } $head = moPrepareHead($object); @@ -144,14 +153,13 @@ if ($object->id > 0) // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->projet->enabled)) - { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($permissiontoadd) - { - if ($action != 'classify') + if ($permissiontoadd) { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref .= ''; @@ -196,10 +204,11 @@ if ($object->id > 0) $out = '&origin='.$object->element.'&originid='.$object->id; $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); @@ -209,10 +218,8 @@ if ($object->id > 0) print ''; - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $param = '&id='.$object->id.'&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } //print load_fiche_titre($langs->trans("ActionsOnMo"), '', ''); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index a95d92d67a1..9afbbaf9acf 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -61,18 +61,20 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } -if (empty($action) && empty($id) && empty($ref)) $action = 'view'; +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -if (GETPOST('fk_bom', 'int')) -{ +if (GETPOST('fk_bom', 'int')) { $objectbom->fetch(GETPOST('fk_bom', 'int')); if ($action != 'add') { @@ -103,18 +105,22 @@ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->enti $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { $error = 0; $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } } } if ($cancel && !empty($backtopageforcancel)) { @@ -141,28 +147,27 @@ if (empty($reshook)) // Action to move up and down lines of object //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'set_thirdparty' && $permissiontoadd) - { + if ($action == 'set_thirdparty' && $permissiontoadd) { $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); } - if ($action == 'classin' && $permissiontoadd) - { + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); } // Action close produced - if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) - { + if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); - if ($result >= 0) - { + if ($result >= 0) { // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -208,15 +213,18 @@ jQuery(document).ready(function() { // Part to create -if ($action == 'create') -{ +if ($action == 'create') { print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'mrp'); print ''; print ''; print ''; - if ($backtopage) print ''; - if ($backtopageforcancel) print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } print dol_get_fiche_head(array(), ''); @@ -234,7 +242,7 @@ if ($action == 'create') ?> '; - if (empty($conf->use_javascript_ajax)) print 'id.'">'; + if (empty($conf->use_javascript_ajax)) { + print 'id.'">'; + } print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) print ''; + if (empty($conf->use_javascript_ajax)) { + print ''; + } } else { if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line print ''; @@ -795,14 +855,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print ''; print ''; print ''; print ''; + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { + print ''; + } print ''; // Lot Batch @@ -821,8 +888,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); - if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; + if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) { + $preselected = 0; + } print ''; + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { + print ''; + } print ''; print '
'.$langs->trans("LatestMOModified", $max).'
'; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print ''.$line2['qty'].''; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) print $tmpwarehouse->getNomUrl(1); + if ($result > 0) { + print $tmpwarehouse->getNomUrl(1); + } } print '
'.$langs->trans("ToConsume").''; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -851,9 +923,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - print '
'; + print '
'; print ''; + // Lines to produce print ''; @@ -868,20 +941,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("PMPValue").''.$langs->trans("UnitCost").''.$langs->trans("QtyAlreadyProduced").''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Warehouse"); + } print ''; - if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print $langs->trans("Batch"); + } print '
'.$line->qty.''; + print price($bomcost); + print ''; if ($alreadyproduced) { print ''; - if (empty($conf->use_javascript_ajax)) print 'id.'">'; + if (empty($conf->use_javascript_ajax)) { + print 'id.'">'; + } print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) print ''; + if (empty($conf->use_javascript_ajax)) { + print ''; + } } print ' '.$alreadyproduced; print '
'; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print ''.$line2['qty'].''; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); - if ($result > 0) print $tmpwarehouse->getNomUrl(1); + if ($result > 0) { + print $tmpwarehouse->getNomUrl(1); + } } print '
'.$langs->trans("ToProduce").''; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -993,6 +1109,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } print ''; if ($tmpproduct->status_batch) { $type = 'batch'; @@ -1013,8 +1130,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } - if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) - { + if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { print "\n"; } } diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 6f3b63f6d4e..75147a3c3f9 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -17,13 +17,14 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -if (!is_object($form)) $form = new Form($db); +if (!is_object($form)) { + $form = new Form($db); +} $qtytoconsumeforline = $this->tpl['qty'] / $this->tpl['efficiency']; /*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { @@ -43,7 +44,9 @@ print ''.($this->tpl['disable_stock_change'] ? yn($this->tpl[ //print ''.$this->tpl['efficiency'].''; //print ''; print '
'."\n"; @@ -432,22 +472,19 @@ if ($resql) print ''; // date - if (!empty($arrayfields['cr.date_sync']['checked'])) - { + if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code - if (!empty($arrayfields['m.code']['checked'])) - { + if (!empty($arrayfields['m.code']['checked'])) { print ''; } // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { + if (!empty($arrayfields['cr.rate']['checked'])) { print ''; @@ -466,9 +503,15 @@ if ($resql) print ''; print ''; - if (!empty($arrayfields['cr.date_sync']['checked'])) print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['m.code']['checked'])) print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['cr.rate']['checked'])) print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print_liste_field_titre($arrayfields['cr.date_sync']['label'], $_SERVER["PHP_SELF"], "cr.date_sync", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['m.code']['checked'])) { + print_liste_field_titre($arrayfields['m.code']['label'], $_SERVER["PHP_SELF"], "m.code", "", $param, "", $sortfield, $sortorder); + } + if (!empty($arrayfields['cr.rate']['checked'])) { + print_liste_field_titre($arrayfields['cr.rate']['label'], $_SERVER["PHP_SELF"], "cr.rate", "", $param, "", $sortfield, $sortorder); + } // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -480,38 +523,40 @@ if ($resql) $i = 0; $totalarray = array(); - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); print ''; // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { + if (!empty($arrayfields['cr.date_sync']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // code - if (!empty($arrayfields['m.code']['checked'])) - { + if (!empty($arrayfields['m.code']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { + if (!empty($arrayfields['cr.rate']['checked'])) { print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Fields from hook @@ -521,16 +566,19 @@ if ($resql) // Action print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "\n"; $i++; @@ -542,8 +590,7 @@ if ($resql) print ""; print ''; -} -else { +} else { dol_print_error($db); } diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index ef583d08ff5..bbd930b013f 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Initialisation des variables $action = GETPOST('action', 'aZ09'); @@ -62,17 +64,21 @@ $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), $parameters = array('id' => $numsondage); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($cancel) $action = ''; +if (empty($reshook)) { + if ($cancel) { + $action = ''; + } // Delete - if ($action == 'delete_confirm') - { + if ($action == 'delete_confirm') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $result = $object->delete($user, '', $numsondage); @@ -81,36 +87,33 @@ if (empty($reshook)) } // Close - if ($action == 'close') - { + if ($action == 'close') { $object->status = Opensurveysondage::STATUS_CLOSED; $object->update($user); } // Reopend - if ($action == 'reopen') - { + if ($action == 'reopen') { $object->status = Opensurveysondage::STATUS_VALIDATED; $object->update($user); } // Update - if ($action == 'update') - { + if ($action == 'update') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $error = 0; - if (!GETPOST('nouveautitre')) - { + if (!GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - if (!$error) - { + if (!$error) { $object->title = (string) GETPOST('nouveautitre', 'alphanohtml'); $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); @@ -128,8 +131,7 @@ if (empty($reshook)) } // Add comment - if (GETPOST('ajoutcomment')) - { + if (GETPOST('ajoutcomment')) { $error = 0; if (!GETPOST('comment')) { @@ -147,8 +149,7 @@ if (empty($reshook)) $resql = $object->addComment($comment, $comment_user); - if (!$resql) - { + if (!$resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } } @@ -156,17 +157,20 @@ if (empty($reshook)) // Delete comment $idcomment = GETPOST('deletecomment', 'int'); - if ($idcomment) - { + if ($idcomment) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $resql = $object->deleteComment($idcomment); } if ($action == 'edit') { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } } } @@ -177,8 +181,7 @@ if (empty($reshook)) $form = new Form($db); -if ($object->fk_user_creat) -{ +if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } @@ -193,8 +196,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -232,16 +234,16 @@ print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'< print ''; // Description print ''; //If linked user, then emails are going to be sent to users' email if (!$object->fk_user_creat) { print ''; } // Receive an email with each vote print ''; // Users can comment print ''; // Users can see others vote print ''; // Expire date print ''; @@ -322,7 +329,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; print ''; -if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url); +if ($action != 'edit') { + print ajax_autoselect("opensurveyurl", $url); +} print ''; @@ -332,8 +341,7 @@ print ''; print dol_get_fiche_end(); -if ($action == 'edit') -{ +if ($action == 'edit') { print '
'; print ''; print '   '; @@ -354,13 +362,11 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { //Modify button print ''.$langs->trans("Modify").''; - if ($object->status == Opensurveysondage::STATUS_VALIDATED) - { + if ($object->status == Opensurveysondage::STATUS_VALIDATED) { //Close button print ''.$langs->trans("Close").''; } - if ($object->status == Opensurveysondage::STATUS_CLOSED) - { + if ($object->status == Opensurveysondage::STATUS_CLOSED) { //Opened button print ''.$langs->trans("ReOpen").''; } @@ -371,8 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { print '
'; -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?&id='.$numsondage, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll", $id), 'delete_confirm', '', '', 1); } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c635c2430a7..badb3f60149 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -175,7 +175,7 @@ class Opensurveysondage extends CommonObject $sql .= "allow_comments,"; $sql .= "allow_spy,"; $sql .= "sujet,"; - $sql .= "entity"; + $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; @@ -188,21 +188,25 @@ class Opensurveysondage extends CommonObject $sql .= " ".((int) $this->allow_comments).","; $sql .= " ".((int) $this->allow_spy).","; $sql .= " '".$this->db->escape($this->sujet)."',"; - $sql .= " ".((int) $conf->entity); + $sql .= " ".((int) $conf->entity); $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } if (!$error && !$notrigger) { global $langs, $conf; // Call trigger $result = $this->call_trigger('OPENSURVEY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } @@ -250,10 +254,8 @@ class Opensurveysondage extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; @@ -336,15 +338,15 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -369,8 +371,7 @@ class Opensurveysondage extends CommonObject global $conf, $langs; $error = 0; - if (empty($numsondage)) - { + if (empty($numsondage)) { $numsondage = $this->id_sondage; } @@ -379,12 +380,13 @@ class Opensurveysondage extends CommonObject if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('OPENSURVEY_DELETE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -397,14 +399,14 @@ class Opensurveysondage extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } } // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { + if ($error) { + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } @@ -431,7 +433,9 @@ class Opensurveysondage extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -444,14 +448,16 @@ class Opensurveysondage extends CommonObject // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -466,8 +472,12 @@ class Opensurveysondage extends CommonObject $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; return $result; @@ -488,19 +498,19 @@ class Opensurveysondage extends CommonObject $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); $ret[] = $tmp; $i++; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } $this->lines = $ret; @@ -543,14 +553,11 @@ class Opensurveysondage extends CommonObject $sql .= " ORDER BY id_comment"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($num_rows > 0) { + while ($obj = $this->db->fetch_object($resql)) { $comments[] = $obj; } } @@ -642,8 +649,7 @@ class Opensurveysondage extends CommonObject // phpcs:enable global $langs, $conf; - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); @@ -656,10 +662,15 @@ class Opensurveysondage extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { - if (0) $statusType = 'status1'; - else $statusType = 'status4'; + if (0) { + $statusType = 'status1'; + } else { + $statusType = 'status4'; + } + } + if ($status == self::STATUS_CLOSED) { + $statusType = 'status6'; } - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php index 6f9a699273b..3a4237f83e6 100644 --- a/htdocs/opensurvey/exportcsv.php +++ b/htdocs/opensurvey/exportcsv.php @@ -30,14 +30,15 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; $action = GETPOST('action', 'aZ09'); $numsondage = ''; -if (GETPOST('id')) -{ +if (GETPOST('id')) { $numsondage = GETPOST("id", 'alpha'); } $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} /* @@ -57,10 +58,8 @@ $toutsujet = explode(",", $object->sujet); // affichage des sujets du sondage $input .= $langs->trans("Name").";"; -for ($i = 0; $toutsujet[$i]; $i++) -{ - if ($object->format == "D") - { +for ($i = 0; $toutsujet[$i]; $i++) { + if ($object->format == "D") { $input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';'; } else { $input .= ''.$toutsujet[$i].';'; @@ -69,11 +68,9 @@ for ($i = 0; $toutsujet[$i]; $i++) $input .= "\r\n"; -if (strpos($object->sujet, '@') !== false) -{ +if (strpos($object->sujet, '@') !== false) { $input .= ";"; - for ($i = 0; $toutsujet[$i]; $i++) - { + for ($i = 0; $toutsujet[$i]; $i++) { $heures = explode("@", $toutsujet[$i]); $input .= ''.$heures[1].';'; } @@ -87,12 +84,10 @@ $sql .= ' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage='".$db->escape($numsondage)."'"; $sql .= " ORDER BY id_users"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); // Le name de l'utilisateur @@ -101,15 +96,12 @@ if ($resql) //affichage des resultats $ensemblereponses = $obj->reponses; - for ($k = 0; $k < $nbcolonnes; $k++) - { + for ($k = 0; $k < $nbcolonnes; $k++) { $car = substr($ensemblereponses, $k, 1); - if ($car == "1") - { + if ($car == "1") { $input .= 'OK;'; $somme[$k]++; - } elseif ($car == "2") - { + } elseif ($car == "2") { $input .= 'KO;'; $somme[$k]++; } else { @@ -120,7 +112,9 @@ if ($resql) $input .= "\r\n"; $i++; } -} else dol_print_error($db); +} else { + dol_print_error($db); +} $filesize = strlen($input); diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 0ea701ebf0b..96d9370c10a 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -96,19 +96,16 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $urllogo = ''; $urllogofull = ''; - if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) - { + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) - { + } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); } // Output html code for logo - if ($urllogo) - { + if ($urllogo) { print '
'; print '
'; print 'load("opensurvey"); // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} $hookmanager = new HookManager($db); @@ -48,11 +50,12 @@ $sql = 'SELECT COUNT(*) as nb'; $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_sondage'; $sql .= ' WHERE entity IN ('.getEntity('survey').')'; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); $nbsondages = $obj->nb; -} else dol_print_error($db, ''); +} else { + dol_print_error($db, ''); +} $title = $langs->trans("OpenSurveyArea"); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index eaee1b696e1..3f0b6011455 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -67,24 +69,29 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "p.date_fin"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "p.date_fin"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Definition of fields for list $arrayfields = array(); -foreach ($arrayfields as $key => $val) -{ +foreach ($arrayfields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) { + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + } } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -107,21 +114,25 @@ $permissiontodelete = $user->rights->opensurvey->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_status = ''; $search_title = ''; $search_ref = ''; @@ -129,8 +140,7 @@ if (empty($reshook)) $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -160,11 +170,21 @@ $sql .= " u.login, u.firstname, u.lastname"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; $sql .= " WHERE p.entity IN (".getEntity('survey').")"; -if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2); -if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'"; -if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; -if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref); -if ($search_title) $sql .= natural_search("p.titre", $search_title); +if ($search_status != '-1' && $search_status != '') { + $sql .= natural_search("p.status", $search_status, 2); +} +if ($search_expired == 'expired') { + $sql .= " AND p.date_fin < '".$db->idate($now)."'"; +} +if ($search_expired == 'opened') { + $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; +} +if ($search_ref) { + $sql .= natural_search("p.id_sondage", $search_ref); +} +if ($search_title) { + $sql .= natural_search("p.titre", $search_title); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -176,26 +196,22 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) -{ +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; } else { $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -204,8 +220,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id); @@ -221,11 +236,17 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname'; -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -234,15 +255,21 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // List of surveys into database print '
'; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -261,9 +288,10 @@ $objecttmp = new Opensurveysondage($db); $trackid = 'surv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) -{ - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); +if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } @@ -274,11 +302,13 @@ $moreforfilter.= '
';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; @@ -346,18 +376,20 @@ print ''."\n"; // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) -{ +while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'"; $resql2 = $db->query($sql2); - if ($resql2) - { + if ($resql2) { $obj2 = $db->fetch_object($resql2); $nbuser = $obj2->nb; - } else dol_print_error($db); + } else { + dol_print_error($db); + } $opensurvey_static->id = $obj->rowid; $opensurvey_static->ref = $obj->rowid; @@ -372,11 +404,15 @@ while ($i < min($num, $limit)) print '
'; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Title print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Type print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Nb of voters print''."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -426,14 +476,17 @@ while ($i < min($num, $limit)) print $hookmanager->resPrint; // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; $i++; @@ -444,10 +497,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 8; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } @@ -463,10 +519,11 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index ea07900ba67..36228939092 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Security check -if (!$user->rights->opensurvey->read) accessforbidden(); +if (!$user->rights->opensurvey->read) { + accessforbidden(); +} // Init vars @@ -40,7 +42,9 @@ $numsondage = GETPOST("id"); $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); +if ($result <= 0) { + dol_print_error('', 'Failed to get survey id '.$numsondage); +} $nblines = $object->fetch_lines(); @@ -58,20 +62,15 @@ if (GETPOST('retoursondage')) { $nbcolonnes = substr_count($object->sujet, ',') + 1; // Add vote -if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox -{ - if (GETPOST('nom')) - { +if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox + if (GETPOST('nom')) { $erreur_prenom = false; $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + for ($i = 0; $i < $nbcolonnes; $i++) { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -87,15 +86,16 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); - if ($num_rows > 0) - { + if ($num_rows > 0) { setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors'); $error++; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } } } @@ -104,35 +104,30 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i = 0; $i < $nblines; $i++) -{ - if (isset($_POST['modifierligne'.$i])) - { +for ($i = 0; $i < $nblines; $i++) { + if (isset($_POST['modifierligne'.$i])) { $ligneamodifier = $i; $testligneamodifier = true; } //test pour voir si une ligne est a modifier - if (isset($_POST['validermodifier'.$i])) - { + if (isset($_POST['validermodifier'.$i])) { $modifier = $i; $testmodifier = true; } } -if ($testmodifier) -{ +if ($testmodifier) { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauchoix = ''; - for ($i = 0; $i < $nbcolonnes; $i++) - { + for ($i = 0; $i < $nbcolonnes; $i++) { //var_dump($_POST["choix$i"]); - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') - { + if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') - { + } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -145,14 +140,17 @@ if ($testmodifier) $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } } // Add column (not for date) -if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") -{ +if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -165,17 +163,19 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } // Add column (with format date) -if (isset($_POST["ajoutercolonne"]) && $object->format == "D") -{ +if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $nouveauxsujets = $object->sujet; @@ -223,8 +223,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $cleinsertion = count($datesbase); } else { $nbdatesbase = count($datesbase); - for ($i = 0; $i < $nbdatesbase; $i++) - { + for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) { $cleinsertion = $j; @@ -244,14 +243,14 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") $dateinsertion = substr("$dateinsertion", 1); // update with new topics into database - if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) - { + if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); - else { + if (!$resql) { + dol_print_error($db); + } else { header('Location: results.php?id='.$object->id_sondage); } } @@ -263,12 +262,12 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } // Delete line -for ($i = 0; $i < $nblines; $i++) -{ - if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox - { +for ($i = 0; $i < $nblines; $i++) { + if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $compteur = 0; @@ -278,14 +277,14 @@ for ($i = 0; $i < $nblines; $i++) $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); - if ($compteur == $i) - { + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); @@ -297,13 +296,13 @@ for ($i = 0; $i < $nblines; $i++) } // Delete column -for ($i = 0; $i < $nbcolonnes; $i++) -{ +for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) - && $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox - { + && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if (!$user->rights->opensurvey->write) { + accessforbidden(); + } $db->begin(); @@ -312,12 +311,12 @@ for ($i = 0; $i < $nbcolonnes; $i++) $nouveauxsujets = ''; //parcours de tous les sujets actuels - while (isset($toutsujet[$j])) - { + while (isset($toutsujet[$j])) { //si le sujet n'est pas celui qui a été effacé alors on concatene - if ($i != $j) - { - if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; + if ($i != $j) { + if (!empty($nouveauxsujets)) { + $nouveauxsujets .= ','; + } $nouveauxsujets .= $toutsujet[$j]; } @@ -328,7 +327,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (!$resql) dol_print_error($db); + if (!$resql) { + dol_print_error($db); + } // Clean current answer to remove deleted columns $compteur = 0; @@ -337,22 +338,19 @@ for ($i = 0; $i < $nbcolonnes; $i++) $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); - while ($compteur < $num) - { + while ($compteur < $num) { $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; // parcours de toutes les réponses actuelles - for ($j = 0; $j < $nbcolonnes; $j++) - { + for ($j = 0; $j < $nbcolonnes; $j++) { $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { @@ -389,8 +387,7 @@ if ($object->fk_user_creat) { } $result = $object->fetch(0, $numsondage); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -405,8 +402,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices $toutsujet = explode(",", $object->sujet); $listofanswers = array(); -foreach ($toutsujet as $value) -{ +foreach ($toutsujet as $value) { $tmp = explode('@', $value); $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } @@ -452,10 +448,13 @@ print ''; // Expire date print ''; @@ -480,8 +479,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai $url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; $urllink = ''; print $urllink; -if ($action != 'edit') -{ +if ($action != 'edit') { print ''; print '
'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ' '; $htmltext = $langs->trans("ProjectFollowTasks"); print ''; print '
'; } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print ''; print '
'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print ' '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -586,28 +567,31 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; // Thirdparty - if ($conf->societe->enabled) - { + if ($conf->societe->enabled) { print ''; } // Status - if ($status != '') - { + if ($status != '') { print ''; @@ -632,8 +620,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0); print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; print '
'; print ''; print ''; print ''; print ''; print ''; print '
'; print $obj->date_sync; print "'; print $obj->code." ".$obj->name; print "'; print $obj->rate; print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print 'rowid.'">'.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } print '
'; $adresseadmin = $object->mail_admin; print $langs->trans("Title").''; -if ($action == 'edit') -{ +if ($action == 'edit') { print ''; -} else print dol_htmlentities($object->title); +} else { + print dol_htmlentities($object->title); +} print '
'.$langs->trans("Description").''; -if ($action == 'edit') -{ +if ($action == 'edit') { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); } else { @@ -253,17 +255,17 @@ print '
'.$langs->trans("EMail").''; - if ($action == 'edit') - { + if ($action == 'edit') { print ''; - } else print dol_print_email($object->mail_admin, 0, 0, 1); + } else { + print dol_print_email($object->mail_admin, 0, 0, 1); + } print '
'.$langs->trans('ToReceiveEMailForEachVote').''; -if ($action == 'edit') -{ +if ($action == 'edit') { print 'mailsonde ? 'checked="checked"' : '').'">'; } else { print yn($object->mailsonde); @@ -279,26 +281,31 @@ print '
'.$langs->trans('CanComment').''; -if ($action == 'edit') -{ +if ($action == 'edit') { print 'allow_comments ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_comments); +} else { + print yn($object->allow_comments); +} print '
'.$langs->trans('CanSeeOthersVote').''; -if ($action == 'edit') -{ +if ($action == 'edit') { print 'allow_spy ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_spy); +} else { + print yn($object->allow_spy); +} print '
'.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '
'; print $opensurvey_static->getNomUrl(1); print ''.dol_htmlentities($obj->title).''; @@ -384,7 +420,9 @@ while ($i < min($num, $limit)) print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate"); print ''; // Author @@ -400,23 +438,35 @@ while ($i < min($num, $limit)) print dol_htmlentities($obj->nom_admin); } print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin), 'day'); - if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } + if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } print ''.dol_print_date($db->jdate($obj->tms), 'dayhour'); print ''.$opensurvey_static->getLibStatut(5).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { +if ($action == 'edit') { + print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +} else { print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) { + print img_warning($langs->trans("Expired")); + } } print '
'; print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; $filteronlist = ''; - if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); - if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) - { + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) { + $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + } + $text = img_picto('', 'company').$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx'); + if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); - } else print $text; - if (!GETPOSTISSET('backtopage')) print ' '; + } else { + print $text; + } + if (!GETPOSTISSET('backtopage')) { + print ' '; + } print '
'.$langs->trans("Status").''; print ''; print $object->LibStatut($status, 4); @@ -617,8 +601,12 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '
'.$langs->trans("Visibility").''; $array = array(); - if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); - if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); + if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) { + $array[0] = $langs->trans("PrivateProject"); + } + if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) { + $array[1] = $langs->trans("SharedProject"); + } print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); print '
'.$langs->trans("OpportunityStatus").''; @@ -678,8 +665,7 @@ if ($action == 'create' && $user->rights->projet->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'create'); } @@ -689,8 +675,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
'; print ''; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { print '     '; print ''; } else { @@ -731,11 +716,10 @@ if ($action == 'create' && $user->rights->projet->creer) }); }); '; -} elseif ($object->id > 0) -{ +} elseif ($object->id > 0) { /* - * Show or edit - */ + * Show or edit + */ $res = $object->fetch_optionals(); @@ -747,34 +731,31 @@ if ($action == 'create' && $user->rights->projet->creer) // Confirmation validation - if ($action == 'validate') - { + if ($action == 'validate') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate', '', 0, 1); } // Confirmation close - if ($action == 'close') - { + if ($action == 'close') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloseAProject"), $langs->trans("ConfirmCloseAProject"), "confirm_close", '', '', 1); } // Confirmation reopen - if ($action == 'reopen') - { + if ($action == 'reopen') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ReOpenAProject"), $langs->trans("ConfirmReOpenAProject"), "confirm_reopen", '', '', 1); } // Confirmation delete - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans("ConfirmDeleteAProject"); $task = new Task($db); $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0); $nboftask = count($taskarray); - if ($nboftask) $text .= '
'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + if ($nboftask) { + $text .= '
'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1); } // Clone confirmation - if ($action == 'clone') - { + if ($action == 'clone') { $formquestion = array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), @@ -798,8 +779,7 @@ if ($action == 'create' && $user->rights->projet->creer) $head = project_prepare_head($object); - if ($action == 'edit' && $userWrite > 0) - { + if ($action == 'edit' && $userWrite > 0) { print dol_get_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); print ''; @@ -818,8 +798,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Status print ''; print ''; // Thirdparty - if ($conf->societe->enabled) - { + if ($conf->societe->enabled) { print ''; } // Visibility print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $classfortr = ($object->usage_opportunity ? '' : ' hideobject'); // Opportunity status print ''; @@ -930,7 +910,9 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; @@ -952,8 +934,7 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; // Tags-Categories - if ($conf->categorie->enabled) - { + if ($conf->categorie->enabled) { print ''; print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print ''; // Opportunity percent print ''; // Opportunity Amount print ''; // Opportunity Weighted Amount print ''; } @@ -1085,12 +1069,16 @@ if ($action == 'create' && $user->rights->projet->creer) $end = dol_print_date($object->date_end, 'day'); print ' - '; print ($end ? $end : '?'); - if ($object->hasDelay()) print img_warning("Late"); + if ($object->hasDelay()) { + print img_warning("Late"); + } print ''; // Budget print ''; // Other attributes @@ -1129,8 +1117,7 @@ if ($action == 'create' && $user->rights->projet->creer) print dol_get_fiche_end(); - if ($action == 'edit' && $userWrite > 0) - { + if ($action == 'edit' && $userWrite > 0) { print '
'; print '     '; print ''; @@ -1140,11 +1127,12 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; // Change probability from status - if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. $defaultcheckedwhenoppclose = 1; - if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0; + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + $defaultcheckedwhenoppclose = 0; + } print ''; print '
'.$langs->trans("Status").''; print ''; @@ -830,8 +809,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print ''; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); @@ -850,22 +828,19 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print '
'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print ' '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -873,34 +848,39 @@ if ($action == 'create' && $user->rights->projet->creer) print '
'; print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; $filteronlist = ''; - if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) { + $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + } $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); - if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) - { + if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); - } else print $text; + } else { + print $text; + } print '
'.$langs->trans("Visibility").''; $array = array(); - if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); - if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); + if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) { + $array[0] = $langs->trans("PrivateProject"); + } + if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) { + $array[1] = $langs->trans("SharedProject"); + } print $form->selectarray('public', $array, $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); print '
'.$langs->trans("OpportunityStatus").'
'.$langs->trans("DateStart").''; print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print '     '.$langs->trans("ProjectReportDate"); print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -969,8 +950,7 @@ if ($action == 'create' && $user->rights->projet->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -987,15 +967,13 @@ if ($action == 'create' && $user->rights->projet->creer) $morehtmlref .= dol_escape_htmltag($object->title); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '; - if ($object->thirdparty->id > 0) - { + if ($object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= ''; // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) - { + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } @@ -1014,30 +992,26 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print '
'; - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) - { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
'; } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } - if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; } - if (!empty($conf->eventorganization->enabled)) - { + if (!empty($conf->eventorganization->enabled)) { print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); @@ -1046,35 +1020,45 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '
'.$langs->trans("Visibility").''; - if ($object->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); + if ($object->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } print '
'.$langs->trans("OpportunityStatus").''; $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) print $langs->trans("OppStatus".$code); + if ($code) { + print $langs->trans("OppStatus".$code); + } print '
'.$langs->trans("OpportunityProbability").''; - if (strcmp($object->opp_percent, '')) print price($object->opp_percent, 0, $langs, 1, 0).' %'; + if (strcmp($object->opp_percent, '')) { + print price($object->opp_percent, 0, $langs, 1, 0).' %'; + } print '
'.$langs->trans("OpportunityAmount").''; /*if ($object->opp_status) - { - print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); - }*/ - if (strcmp($object->opp_amount, '')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($object->opp_amount, '')) { + print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + } print '
'.$langs->trans('OpportunityWeightedAmount').''; - if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + if (strcmp($object->opp_amount, '') && strcmp($object->opp_percent, '')) { + print price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency); + } print '
'.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($object->budget_amount, '')) { + print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + } print '