From c8baaa2995d5f04be6b41ab785205ecdac673e14 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 16 Dec 2019 12:06:25 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/bookkeeping/list.php | 214 ++--- htdocs/admin/mails_templates.php | 560 ++++++------- htdocs/admin/modules.php | 470 +++++------ htdocs/admin/perms.php | 62 +- htdocs/admin/propal.php | 172 ++-- htdocs/admin/reception_setup.php | 120 +-- htdocs/admin/supplier_proposal.php | 18 +- htdocs/admin/user.php | 64 +- htdocs/admin/usergroup.php | 68 +- htdocs/bookmarks/list.php | 76 +- htdocs/comm/action/pertype.php | 750 +++++++++--------- htdocs/comm/mailing/cibles.php | 4 +- htdocs/comm/propal/list.php | 62 +- htdocs/commande/list.php | 88 +- htdocs/compta/deplacement/stats/index.php | 86 +- htdocs/compta/facture/list.php | 128 +-- htdocs/compta/sociales/list.php | 128 +-- htdocs/compta/stats/cabyuser.php | 210 ++--- htdocs/compta/stats/casoc.php | 274 +++---- htdocs/contact/list.php | 422 +++++----- htdocs/core/ajax/ajaxdirpreview.php | 168 ++-- htdocs/core/ajax/ajaxdirtree.php | 230 +++--- htdocs/core/class/html.form.class.php | 216 ++--- htdocs/core/get_info.php | 88 +- htdocs/core/lib/admin.lib.php | 588 +++++++------- htdocs/core/lib/ldap.lib.php | 32 +- htdocs/core/lib/price.lib.php | 156 ++-- .../doc/doc_generic_shipment_odt.modules.php | 276 +++---- .../doc/doc_generic_invoice_odt.modules.php | 272 +++---- .../modules/printing/printgcp.modules.php | 90 +-- .../modules/printing/printipp.modules.php | 86 +- .../doc/doc_generic_reception_odt.modules.php | 286 +++---- .../doc/doc_generic_stock_odt.modules.php | 256 +++--- ...doc_generic_supplier_order_odt.modules.php | 282 +++---- ..._generic_supplier_proposal_odt.modules.php | 306 +++---- .../user/doc/doc_generic_user_odt.modules.php | 258 +++--- .../doc/doc_generic_usergroup_odt.modules.php | 286 +++---- htdocs/core/tpl/objectline_view.tpl.php | 118 +-- htdocs/core/tpl/passwordforgotten.tpl.php | 58 +- htdocs/margin/tabs/thirdpartyMargins.php | 104 +-- htdocs/mrp/class/mo.class.php | 34 +- htdocs/product/stats/commande_fournisseur.php | 124 +-- htdocs/product/stats/contrat.php | 114 +-- htdocs/product/stats/facture_fournisseur.php | 114 +-- htdocs/product/stats/propal.php | 128 +-- htdocs/product/stats/supplier_proposal.php | 126 +-- htdocs/public/opensurvey/studs.php | 274 +++---- htdocs/salaries/list.php | 152 ++-- htdocs/theme/eldy/global.inc.php | 12 +- htdocs/theme/md/style.css.php | 2 +- 50 files changed, 4606 insertions(+), 4606 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 758906cb19d..b55a3f696fd 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -169,8 +169,8 @@ $error = 0; if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$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 (empty($reshook)) @@ -207,111 +207,111 @@ if (empty($reshook)) // Must be after the remove filter action, before the export. $param = ''; - $filter = array (); - if (! empty($search_date_start)) { + $filter = array(); + if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $tmp=dol_getdate($search_date_start); - $param .= '&search_date_startmonth=' . $tmp['mon'] . '&search_date_startday=' . $tmp['mday'] . '&search_date_startyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_start); + $param .= '&search_date_startmonth='.$tmp['mon'].'&search_date_startday='.$tmp['mday'].'&search_date_startyear='.$tmp['year']; } - if (! empty($search_date_end)) { + if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $tmp=dol_getdate($search_date_end); - $param .= '&search_date_endmonth=' . $tmp['mon'] . '&search_date_endday=' . $tmp['mday'] . '&search_date_endyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_end); + $param .= '&search_date_endmonth='.$tmp['mon'].'&search_date_endday='.$tmp['mday'].'&search_date_endyear='.$tmp['year']; } - if (! empty($search_doc_date)) { + if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $tmp=dol_getdate($search_doc_date); - $param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year']; + $tmp = dol_getdate($search_doc_date); + $param .= '&doc_datemonth='.$tmp['mon'].'&doc_dateday='.$tmp['mday'].'&doc_dateyear='.$tmp['year']; } - if (! empty($search_doc_type)) { + if (!empty($search_doc_type)) { $filter['t.doc_type'] = $search_doc_type; - $param .= '&search_doc_type=' . urlencode($search_doc_type); + $param .= '&search_doc_type='.urlencode($search_doc_type); } - if (! empty($search_doc_ref)) { + if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + $param .= '&search_doc_ref='.urlencode($search_doc_ref); } - if (! empty($search_accountancy_code)) { + if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; - $param .= '&search_accountancy_code=' . urlencode($search_accountancy_code); + $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); } - if (! empty($search_accountancy_code_start)) { + if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); } - if (! empty($search_accountancy_code_end)) { + if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } - if (! empty($search_accountancy_aux_code)) { + if (!empty($search_accountancy_aux_code)) { $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code); + $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); } - if (! empty($search_accountancy_aux_code_start)) { + if (!empty($search_accountancy_aux_code_start)) { $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; - $param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start); + $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); } - if (! empty($search_accountancy_aux_code_end)) { + if (!empty($search_accountancy_aux_code_end)) { $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; - $param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end); + $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); } - if (! empty($search_mvt_label)) { + if (!empty($search_mvt_label)) { $filter['t.label_operation'] = $search_mvt_label; - $param .= '&search_mvt_label=' . urlencode($search_mvt_label); + $param .= '&search_mvt_label='.urlencode($search_mvt_label); } - if (! empty($search_direction)) { + if (!empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . urlencode($search_direction); + $param .= '&search_direction='.urlencode($search_direction); } - if (! empty($search_ledger_code)) { + if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + $param .= '&search_ledger_code='.urlencode($search_ledger_code); } - if (! empty($search_mvt_num)) { + if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode($search_mvt_num); } - if (! empty($search_date_creation_start)) { + if (!empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; - $tmp=dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth=' . $tmp['mon'] . '&date_creation_startday=' . $tmp['mday'] . '&date_creation_startyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_creation_start); + $param .= '&date_creation_startmonth='.$tmp['mon'].'&date_creation_startday='.$tmp['mday'].'&date_creation_startyear='.$tmp['year']; } - if (! empty($search_date_creation_end)) { + if (!empty($search_date_creation_end)) { $filter['t.date_creation<='] = $search_date_creation_end; - $tmp=dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth=' . $tmp['mon'] . '&date_creation_endday=' . $tmp['mday'] . '&date_creation_endyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_creation_end); + $param .= '&date_creation_endmonth='.$tmp['mon'].'&date_creation_endday='.$tmp['mday'].'&date_creation_endyear='.$tmp['year']; } - if (! empty($search_date_modification_start)) { + if (!empty($search_date_modification_start)) { $filter['t.tms>='] = $search_date_modification_start; - $tmp=dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth=' . $tmp['mon'] . '&date_modification_startday=' . $tmp['mday'] . '&date_modification_startyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_modification_start); + $param .= '&date_modification_startmonth='.$tmp['mon'].'&date_modification_startday='.$tmp['mday'].'&date_modification_startyear='.$tmp['year']; } - if (! empty($search_date_modification_end)) { + if (!empty($search_date_modification_end)) { $filter['t.tms<='] = $search_date_modification_end; - $tmp=dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_modification_end); + $param .= '&date_modification_endmonth='.$tmp['mon'].'&date_modification_endday='.$tmp['mday'].'&date_modification_endyear='.$tmp['year']; } - if (! empty($search_date_export_start)) { + if (!empty($search_date_export_start)) { $filter['t.date_export>='] = $search_date_export_start; - $tmp=dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth=' . $tmp['mon'] . '&date_export_startday=' . $tmp['mday'] . '&date_export_startyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_export_start); + $param .= '&date_export_startmonth='.$tmp['mon'].'&date_export_startday='.$tmp['mday'].'&date_export_startyear='.$tmp['year']; } - if (! empty($search_date_export_end)) { + if (!empty($search_date_export_end)) { $filter['t.date_export<='] = $search_date_export_end; - $tmp=dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth=' . $tmp['mon'] . '&date_export_endday=' . $tmp['mday'] . '&date_export_endyear=' . $tmp['year']; + $tmp = dol_getdate($search_date_export_end); + $param .= '&date_export_endmonth='.$tmp['mon'].'&date_export_endday='.$tmp['mday'].'&date_export_endyear='.$tmp['year']; } - if (! empty($search_debit)) { + if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . urlencode($search_debit); + $param .= '&search_debit='.urlencode($search_debit); } - if (! empty($search_credit)) { + if (!empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . urlencode($search_credit); + $param .= '&search_credit='.urlencode($search_credit); } - if (! empty($search_lettering_code)) { + if (!empty($search_lettering_code)) { $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code=' . urlencode($search_lettering_code); + $param .= '&search_lettering_code='.urlencode($search_lettering_code); } } @@ -325,7 +325,7 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri } // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param?'?'.$param:'')); + header("Location: list.php".($param ? '?'.$param : '')); exit; } } @@ -872,125 +872,125 @@ while ($i < min($num, $limit)) print ''; // Piece number - if (! empty($arrayfields['t.piece_num']['checked'])) + if (!empty($arrayfields['t.piece_num']['checked'])) { print ''; $object->id = $line->id; $object->piece_num = $line->piece_num; print $object->getNomUrl(1, '', 0, '', 1); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Document date - if (! empty($arrayfields['t.doc_date']['checked'])) + if (!empty($arrayfields['t.doc_date']['checked'])) { - print '' . dol_print_date($line->doc_date, 'day') . ''; - if (! $i) $totalarray['nbfield']++; + print ''.dol_print_date($line->doc_date, 'day').''; + if (!$i) $totalarray['nbfield']++; } // Document ref - if (! empty($arrayfields['t.doc_ref']['checked'])) + if (!empty($arrayfields['t.doc_ref']['checked'])) { - print '' . $line->doc_ref . ''; - if (! $i) $totalarray['nbfield']++; + print ''.$line->doc_ref.''; + if (!$i) $totalarray['nbfield']++; } // Account number - if (! empty($arrayfields['t.numero_compte']['checked'])) + if (!empty($arrayfields['t.numero_compte']['checked'])) { - print '' . length_accountg($line->numero_compte) . ''; - if (! $i) $totalarray['nbfield']++; + print ''.length_accountg($line->numero_compte).''; + if (!$i) $totalarray['nbfield']++; } // Subledger account - if (! empty($arrayfields['t.subledger_account']['checked'])) + if (!empty($arrayfields['t.subledger_account']['checked'])) { - print '' . length_accounta($line->subledger_account) . ''; - if (! $i) $totalarray['nbfield']++; + print ''.length_accounta($line->subledger_account).''; + if (!$i) $totalarray['nbfield']++; } // Label operation - if (! empty($arrayfields['t.label_operation']['checked'])) + if (!empty($arrayfields['t.label_operation']['checked'])) { - print '' . $line->label_operation . ''; - if (! $i) $totalarray['nbfield']++; + print ''.$line->label_operation.''; + if (!$i) $totalarray['nbfield']++; } // Amount debit - if (! empty($arrayfields['t.debit']['checked'])) + if (!empty($arrayfields['t.debit']['checked'])) { - print '' . ($line->debit ? price($line->debit) : ''). ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totaldebit'; + print ''.($line->debit ? price($line->debit) : '').''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; $totalarray['val']['totaldebit'] += $line->debit; } // Amount credit - if (! empty($arrayfields['t.credit']['checked'])) + if (!empty($arrayfields['t.credit']['checked'])) { - print '' . ($line->credit ? price($line->credit) : '') . ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalcredit'; + print ''.($line->credit ? price($line->credit) : '').''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['val']['totalcredit'] += $line->credit; } // Lettering code - if (! empty($arrayfields['t.lettering_code']['checked'])) + if (!empty($arrayfields['t.lettering_code']['checked'])) { - print '' . $line->lettering_code . ''; - if (! $i) $totalarray['nbfield']++; + print ''.$line->lettering_code.''; + if (!$i) $totalarray['nbfield']++; } // Journal code - if (! empty($arrayfields['t.code_journal']['checked'])) + if (!empty($arrayfields['t.code_journal']['checked'])) { $accountingjournal = new AccountingJournal($db); $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print '' . $journaltoshow . ''; - if (! $i) $totalarray['nbfield']++; + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''.$journaltoshow.''; + if (!$i) $totalarray['nbfield']++; } // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Creation operation date - if (! empty($arrayfields['t.date_creation']['checked'])) + if (!empty($arrayfields['t.date_creation']['checked'])) { - print '' . dol_print_date($line->date_creation, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; + print ''.dol_print_date($line->date_creation, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; } // Modification operation date - if (! empty($arrayfields['t.tms']['checked'])) + if (!empty($arrayfields['t.tms']['checked'])) { - print '' . dol_print_date($line->date_modification, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; + print ''.dol_print_date($line->date_modification, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; } // Exported operation date - if (! empty($arrayfields['t.date_export']['checked'])) + if (!empty($arrayfields['t.date_export']['checked'])) { - print '' . dol_print_date($line->date_export, 'dayhour') . ''; - if (! $i) $totalarray['nbfield']++; + print ''.dol_print_date($line->date_export, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; if (empty($line->date_export)) { if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; + print ''.img_edit().''; } if ($user->rights->accounting->mouvements->supprimer) { - print ' ' . img_delete() . ''; + print ' '.img_delete().''; } } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 47300a5530d..05049a5c739 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -43,133 +43,133 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","mails","languages")); +$langs->loadLangs(array("errors", "admin", "mails", "languages")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'alpha'); -$search_label=GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)' -$search_type_template=GETPOST('search_type_template', 'alpha'); -$search_lang=GETPOST('search_lang', 'alpha'); -$search_fk_user=GETPOST('search_fk_user', 'intcomma'); -$search_topic=GETPOST('search_topic', 'alpha'); +$search_label = GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)' +$search_type_template = GETPOST('search_type_template', 'alpha'); +$search_lang = GETPOST('search_lang', 'alpha'); +$search_fk_user = GETPOST('search_fk_user', 'intcomma'); +$search_topic = GETPOST('search_topic', 'alpha'); -if (! empty($user->socid)) accessforbidden(); +if (!empty($user->socid)) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); -$listoffset=GETPOST('listoffset', 'alpha'); -$listlimit =GETPOST('listlimit', 'alpha')>0?GETPOST('listlimit', 'alpha'):1000; +$listoffset = GETPOST('listoffset', 'alpha'); +$listlimit = GETPOST('listlimit', 'alpha') > 0 ?GETPOST('listlimit', 'alpha') : 1000; $active = 1; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $listlimit * $page ; +$offset = $listlimit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (empty($sortfield)) $sortfield='type_template, lang, position, label'; -if (empty($sortorder)) $sortorder='ASC'; +if (empty($sortfield)) $sortfield = 'type_template, lang, position, label'; +if (empty($sortorder)) $sortorder = 'ASC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('emailtemplates')); // Name of SQL tables of dictionaries -$tabname=array(); -$tabname[25]= MAIN_DB_PREFIX."c_email_templates"; +$tabname = array(); +$tabname[25] = MAIN_DB_PREFIX."c_email_templates"; // Nom des champs en resultat de select pour affichage du dictionnaire -$tabfield=array(); -$tabfield[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; -if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines'; +$tabfield = array(); +$tabfield[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25] .= ',content_lines'; // Nom des champs d'edition pour modification d'un enregistrement -$tabfieldvalue=array(); -$tabfieldvalue[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; -if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines'; +$tabfieldvalue = array(); +$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25] .= ',content_lines'; // Nom des champs dans la table pour insertion d'un enregistrement -$tabfieldinsert=array(); -$tabfieldinsert[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; -if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines'; -$tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays +$tabfieldinsert = array(); +$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25] .= ',content_lines'; +$tabfieldinsert[25] .= ',entity'; // Must be at end because not into other arrays // Condition to show dictionary in setup page -$tabcond=array(); -$tabcond[25]= true; +$tabcond = array(); +$tabcond[25] = true; // List of help for fields // Set MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES to allow edit of template for lines require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; -$formmail=new FormMail($db); +$formmail = new FormMail($db); if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { - $tmp=FormMail::getAvailableSubstitKey('formemail'); - $tmp['__(AnyTranslationKey)__']='Translation'; + $tmp = FormMail::getAvailableSubstitKey('formemail'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; $helpsubstit = $langs->trans("AvailableVariables").':
'; $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach($tmp as $key => $val) + foreach ($tmp as $key => $val) { - $helpsubstit.=$key.' -> '.$val.'
'; - $helpsubstitforlines.=$key.' -> '.$val.'
'; + $helpsubstit .= $key.' -> '.$val.'
'; + $helpsubstitforlines .= $key.' -> '.$val.'
'; } } else { - $tmp=FormMail::getAvailableSubstitKey('formemailwithlines'); - $tmp['__(AnyTranslationKey)__']='Translation'; + $tmp = FormMail::getAvailableSubstitKey('formemailwithlines'); + $tmp['__(AnyTranslationKey)__'] = 'Translation'; $helpsubstit = $langs->trans("AvailableVariables").':
'; $helpsubstitforlines = $langs->trans("AvailableVariables").':
'; - foreach($tmp as $key => $val) + foreach ($tmp as $key => $val) { - $helpsubstit.=$key.' -> '.$val.'
'; + $helpsubstit .= $key.' -> '.$val.'
'; } - $tmp=FormMail::getAvailableSubstitKey('formemailforlines'); - foreach($tmp as $key => $val) + $tmp = FormMail::getAvailableSubstitKey('formemailforlines'); + foreach ($tmp as $key => $val) { - $helpsubstitforlines.=$key.' -> '.$val.'
'; + $helpsubstitforlines .= $key.' -> '.$val.'
'; } } -$tabhelp=array(); -$tabhelp[25] = array('topic'=>$helpsubstit,'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit,'content_lines'=>$helpsubstitforlines,'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp = array(); +$tabhelp[25] = array('topic'=>$helpsubstit, 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit, 'content_lines'=>$helpsubstitforlines, 'type_template'=>$langs->trans("TemplateForElement"), 'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); // List of check for fields (NOT USED YET) -$tabfieldcheck=array(); +$tabfieldcheck = array(); $tabfieldcheck[25] = array(); // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); -$sourceList=array(); +$sourceList = array(); // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); -if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); -if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); -if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); -if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); -if ($conf->reception->enabled) $elementList['reception_send']=$langs->trans('MailToSendReception'); -if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); -if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation'); -if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); -if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); -if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); -if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); -if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); -if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); -$elementList['user']=$langs->trans('MailToUser'); +if ($conf->propal->enabled) $elementList['propal_send'] = $langs->trans('MailToSendProposal'); +if ($conf->commande->enabled) $elementList['order_send'] = $langs->trans('MailToSendOrder'); +if ($conf->facture->enabled) $elementList['facture_send'] = $langs->trans('MailToSendInvoice'); +if ($conf->expedition->enabled) $elementList['shipping_send'] = $langs->trans('MailToSendShipment'); +if ($conf->reception->enabled) $elementList['reception_send'] = $langs->trans('MailToSendReception'); +if ($conf->ficheinter->enabled) $elementList['fichinter_send'] = $langs->trans('MailToSendIntervention'); +if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send'] = $langs->trans('MailToSendSupplierRequestForQuotation'); +if ($conf->fournisseur->enabled) $elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder'); +if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice'); +if ($conf->societe->enabled) $elementList['thirdparty'] = $langs->trans('MailToThirdparty'); +if ($conf->adherent->enabled) $elementList['member'] = $langs->trans('MailToMember'); +if ($conf->contrat->enabled) $elementList['contract'] = $langs->trans('MailToSendContract'); +if ($conf->projet->enabled) $elementList['project'] = $langs->trans('MailToProject'); +$elementList['user'] = $langs->trans('MailToUser'); -$parameters=array('elementList'=>$elementList); -$reshook=$hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks +$parameters = array('elementList'=>$elementList); +$reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks if ($reshook == 0) { foreach ($hookmanager->resArray as $item => $value) { $elementList[$item] = $value; @@ -177,8 +177,8 @@ if ($reshook == 0) { } // Add all and none after the sort -$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; -$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; +$elementList['all'] = '-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; +$elementList['none'] = '-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; asort($elementList); @@ -189,37 +189,37 @@ $id = 25; * 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 +$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)) { // 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_label=''; - $search_type_template=''; - $search_lang=''; - $search_fk_user=''; - $search_topic=''; - $toselect=''; - $search_array_options=array(); + $search_label = ''; + $search_type_template = ''; + $search_lang = ''; + $search_fk_user = ''; + $search_topic = ''; + $toselect = ''; + $search_array_options = array(); } // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield=explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert=explode(',', $tabfieldinsert[$id]); - $listfieldmodify=explode(',', $tabfieldinsert[$id]); - $listfieldvalue=explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); // Check that all fields are filled - $ok=1; + $ok = 1; foreach ($listfield as $f => $value) { // Not mandatory fields @@ -227,14 +227,14 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') + if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { - $ok=0; - $fieldnamekey=$listfield[$f]; + $ok = 0; + $fieldnamekey = $listfield[$f]; // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Code'; + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Code'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate'; @@ -253,36 +253,36 @@ if (empty($reshook)) // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; // List of values - $i=0; + $i = 0; foreach ($listfieldinsert as $f => $value) { //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); - $keycode=$listfieldvalue[$i]; + $keycode = $listfieldvalue[$i]; if ($value == 'label') $_POST[$keycode] = dol_escape_htmltag($_POST[$keycode]); - if ($value == 'lang') $keycode='langcode'; + if ($value == 'lang') $keycode = 'langcode'; if ($value == 'entity') $_POST[$keycode] = $conf->entity; - if ($i) $sql.=","; - if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; - if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; - if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work - else $sql.="'".$db->escape($_POST[$keycode])."'"; + if ($i) $sql .= ","; + if ($value == 'fk_user' && !($_POST[$keycode] > 0)) $_POST[$keycode] = ''; + if ($value == 'private' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '0'; + if ($value == 'position' && !is_numeric($_POST[$keycode])) $_POST[$keycode] = '1'; + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql .= "null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql .= "''"; // lang must be '' if not defined so the unique key that include lang will work + else $sql .= "'".$db->escape($_POST[$keycode])."'"; $i++; } - $sql.=",1)"; + $sql .= ",1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id'=>$id); // Clean $_POST array, we keep only } else { @@ -298,7 +298,7 @@ if (empty($reshook)) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify')) { - $rowidcol="rowid"; + $rowidcol = "rowid"; // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; @@ -306,27 +306,27 @@ if (empty($reshook)) $i = 0; foreach ($listfieldmodify as $field) { - $keycode=$listfieldvalue[$i]; - if ($field == 'lang') $keycode='langcode'; + $keycode = $listfieldvalue[$i]; + if ($field == 'lang') $keycode = 'langcode'; - if ($field == 'fk_user' && ! ($_POST['fk_user'] > 0)) $_POST['fk_user']=''; - if ($field == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; - if ($field == 'joinfiles') $_POST['joinfiles']=$_POST['joinfiles-'.$rowid]; - if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; - if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; + if ($field == 'fk_user' && !($_POST['fk_user'] > 0)) $_POST['fk_user'] = ''; + if ($field == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; + if ($field == 'joinfiles') $_POST['joinfiles'] = $_POST['joinfiles-'.$rowid]; + if ($field == 'content') $_POST['content'] = $_POST['content-'.$rowid]; + if ($field == 'content_lines') $_POST['content_lines'] = $_POST['content_lines-'.$rowid]; if ($field == 'entity') $_POST[$keycode] = $conf->entity; - if ($i) $sql.=","; - $sql.= $field."="; + if ($i) $sql .= ","; + $sql .= $field."="; //print $keycode.' - '.$_POST[$keycode].'
'; - if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 - elseif ($keycode == 'position') $sql.=((int) $_POST[$keycode]); - else $sql.="'".$db->escape($_POST[$keycode])."'"; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && empty($_POST[$keycode]))) $sql .= "null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql .= "''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql .= ((int) $_POST[$keycode]); // private must be 0 or 1 + elseif ($keycode == 'position') $sql .= ((int) $_POST[$keycode]); + else $sql .= "'".$db->escape($_POST[$keycode])."'"; $i++; } - $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; //print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; @@ -344,13 +344,13 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - $rowidcol="rowid"; + $rowidcol = "rowid"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { @@ -366,7 +366,7 @@ if (empty($reshook)) // activate if ($action == $acts[0]) { - $rowidcol="rowid"; + $rowidcol = "rowid"; $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; @@ -380,7 +380,7 @@ if (empty($reshook)) // disable if ($action == $acts[1]) { - $rowidcol="rowid"; + $rowidcol = "rowid"; $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; @@ -398,13 +398,13 @@ if (empty($reshook)) */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); llxHeader(); -$titre=$langs->trans("EMailsSetup"); -$linkback=''; -$titlepicto='title_setup'; +$titre = $langs->trans("EMailsSetup"); +$linkback = ''; +$titlepicto = 'title_setup'; print load_fiche_titre($titre, $linkback, $titlepicto); @@ -415,35 +415,35 @@ dol_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); -$sql="SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active"; -$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates"; -$sql.=" WHERE entity IN (".getEntity('email_template').")"; -if (! $user->admin) +$sql = "SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates"; +$sql .= " WHERE entity IN (".getEntity('email_template').")"; +if (!$user->admin) { - $sql.=" AND (private = 0 OR (private = 1 AND fk_user = ".$user->id."))"; // Show only public and private to me - $sql.=" AND (active = 1 OR fk_user = ".$user->id.")"; // Show only active or owned by me + $sql .= " AND (private = 0 OR (private = 1 AND fk_user = ".$user->id."))"; // Show only public and private to me + $sql .= " AND (active = 1 OR fk_user = ".$user->id.")"; // Show only active or owned by me } if (empty($conf->global->MAIN_MULTILANGS)) { - $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')"; + $sql .= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')"; } -if ($search_label) $sql.=natural_search('label', $search_label); -if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template); -if ($search_lang) $sql.=natural_search('lang', $search_lang); -if ($search_fk_user != '' && $search_fk_user != '-1') $sql.=natural_search('fk_user', $search_fk_user, 2); -if ($search_topic) $sql.=natural_search('topic', $search_topic); +if ($search_label) $sql .= natural_search('label', $search_label); +if ($search_type_template != '' && $search_type_template != '-1') $sql .= natural_search('type_template', $search_type_template); +if ($search_lang) $sql .= natural_search('lang', $search_lang); +if ($search_fk_user != '' && $search_fk_user != '-1') $sql .= natural_search('fk_user', $search_fk_user, 2); +if ($search_topic) $sql .= natural_search('topic', $search_topic); // If sort order is "country", we use country_code instead -if ($sortfield == 'country') $sortfield='country_code'; -$sql.=$db->order($sortfield, $sortorder); -$sql.=$db->plimit($listlimit+1, $offset); +if ($sortfield == 'country') $sortfield = 'country_code'; +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($listlimit + 1, $offset); //print $sql; -$fieldlist=explode(',', $tabfield[$id]); +$fieldlist = explode(',', $tabfield[$id]); // Form to add a new line print '
'; @@ -459,38 +459,38 @@ foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees - $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate - $align="left"; - if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");} - if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? ' ' : $langs->trans("Language")); } - if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='private') { $align='center'; } - if ($fieldlist[$field]=='position') { $align='center'; } + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $align = "left"; + if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = (empty($conf->global->MAIN_MULTILANGS) ? ' ' : $langs->trans("Language")); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } + if ($fieldlist[$field] == 'private') { $align = 'center'; } + if ($fieldlist[$field] == 'position') { $align = 'center'; } - if ($fieldlist[$field]=='topic') { $valuetoshow=''; } - if ($fieldlist[$field]=='joinfiles') { $valuetoshow=''; } - if ($fieldlist[$field]=='content') { $valuetoshow=''; } - if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; } + if ($fieldlist[$field] == 'topic') { $valuetoshow = ''; } + if ($fieldlist[$field] == 'joinfiles') { $valuetoshow = ''; } + if ($fieldlist[$field] == 'content') { $valuetoshow = ''; } + if ($fieldlist[$field] == 'content_lines') { $valuetoshow = ''; } if ($valuetoshow != '') { print ''; - if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (! empty($tabhelp[$id][$value])) + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) { - if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click - else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover + if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click + else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover } else print $valuetoshow; print ''; } } print ''; -print ''; +print ''; print ''; print ''; @@ -515,7 +515,7 @@ $errors = $hookmanager->errors; // Line to enter new values (input fields) -print ""; +print ""; if (empty($reshook)) { @@ -532,29 +532,29 @@ print ""; // Show fields for topic, join files and body $fieldsforcontent = array('topic', 'joinfiles', 'content'); -if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('content','content_lines'); } +if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { print ''; // Label if ($tmpfieldlist == 'topic') { - print '' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . ' '; + print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } if ($tmpfieldlist == 'joinfiles') { - print '' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . ' '; + print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } if ($tmpfieldlist == 'content') print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; if ($tmpfieldlist == 'content_lines') - print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '
'; + print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; // Input field if ($tmpfieldlist == 'topic') { - print ''; + print ''; } elseif ($tmpfieldlist == 'joinfiles') { - print ''; + print ''; } else { @@ -563,7 +563,7 @@ foreach ($fieldsforcontent as $tmpfieldlist) $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); + $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); print $doleditor->Create(1); } else @@ -571,9 +571,9 @@ foreach ($fieldsforcontent as $tmpfieldlist) } print ''; if ($tmpfieldlist == 'topic') { - print ''; + print ''; if ($action != 'edit') { - print ''; + print ''; } print ''; } @@ -583,7 +583,7 @@ foreach ($fieldsforcontent as $tmpfieldlist) -$colspan=count($fieldlist)+1; +$colspan = count($fieldlist) + 1; //print ' '; // Keep   to have a line with enough height print ''; @@ -601,36 +601,36 @@ print ''; // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $param = '&id='.$id; - if ($search_label) $param.= '&search_label='.urlencode($search_label); - if ($search_lang > 0) $param.= '&search_lang='.urlencode($search_lang); - if ($search_type_template != '-1') $param.= '&search_type_template='.urlencode($search_type_template); - if ($search_fk_user > 0) $param.= '&search_fk_user='.urlencode($search_fk_user); - if ($search_topic) $param.= '&search_topic='.urlencode($search_topic); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_lang > 0) $param .= '&search_lang='.urlencode($search_lang); + if ($search_type_template != '-1') $param .= '&search_type_template='.urlencode($search_type_template); + if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); + if ($search_topic) $param .= '&search_topic='.urlencode($search_topic); $paramwithsearch = $param; - if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); - if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); - if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.urlencode(GETPOST('from', 'alpha')); + if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); + if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); // There is several pages if ($num > $listlimit) { - print ''; } // Title line with search boxes print ''; - $filterfound=0; + $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($value == 'label') print ''; @@ -643,8 +643,8 @@ if ($resql) elseif ($value == 'fk_user') { print ''; @@ -654,12 +654,12 @@ if ($resql) { print ''; } - elseif (! in_array($value, array('content', 'content_lines'))) print ''; + elseif (!in_array($value, array('content', 'content_lines'))) print ''; } if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; // Action column print ''; print ''; @@ -668,11 +668,11 @@ if ($resql) print ''; foreach ($fieldlist as $field => $value) { - $showfield=1; // By defaut - $align="left"; - $sortable=1; - $valuetoshow=''; - $forcenowrap=1; + $showfield = 1; // By defaut + $align = "left"; + $sortable = 1; + $valuetoshow = ''; + $forcenowrap = 1; /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; @@ -680,33 +680,33 @@ if ($resql) $align=$tmp['align']; $sortable=$tmp['sortable']; */ - $valuetoshow=ucfirst($fieldlist[$field]); // By defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='private') { $align='center'; } - if ($fieldlist[$field]=='position') { $align='center'; } + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } + if ($fieldlist[$field] == 'private') { $align = 'center'; } + if ($fieldlist[$field] == 'position') { $align = 'center'; } - if ($fieldlist[$field]=='joinfiles') { $valuetoshow=$langs->trans("FilesAttachedToEmail"); $align='center'; $forcenowrap=0; } - if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); $showfield=0;} - if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); $showfield=0; } + if ($fieldlist[$field] == 'joinfiles') { $valuetoshow = $langs->trans("FilesAttachedToEmail"); $align = 'center'; $forcenowrap = 0; } + if ($fieldlist[$field] == 'content') { $valuetoshow = $langs->trans("Content"); $showfield = 0; } + if ($fieldlist[$field] == 'content_lines') { $valuetoshow = $langs->trans("ContentLines"); $showfield = 0; } // Show fields if ($showfield) { - if (! empty($tabhelp[$id][$value])) + if (!empty($tabhelp[$id][$value])) { - if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click - else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover + if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click + else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList(''); print ''; @@ -717,14 +717,14 @@ if ($resql) { $obj = $db->fetch_object($resql); - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { print ''; - $tmpaction='edit'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; // Show fields if (empty($reshook)) fieldList($fieldlist, $obj, $tabname[$id], 'edit'); @@ -734,12 +734,12 @@ if ($resql) print ''; print ''; print ''; - print '
'; + print '
'; print ''; print ''; $fieldsforcontent = array('topic', 'joinfiles', 'content'); - if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) + if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } @@ -757,20 +757,20 @@ if ($resql) print ''; @@ -783,42 +783,42 @@ if ($resql) } else { - $keyforobj='type_template'; - if (! in_array($obj->$keyforobj, array_keys($elementList))) + $keyforobj = 'type_template'; + if (!in_array($obj->$keyforobj, array_keys($elementList))) { $i++; - continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) + continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) } // Test on 'enabled' - if (! dol_eval($obj->enabled, 1)) + if (!dol_eval($obj->enabled, 1)) { $i++; - continue; // Email template not qualified + continue; // Email template not qualified } print ''; $tmpaction = 'view'; - $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { foreach ($fieldlist as $field => $value) { - if (in_array($fieldlist[$field], array('content','content_lines'))) continue; - $showfield=1; - $align="left"; - $valuetoshow=$obj->{$fieldlist[$field]}; + if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; if ($value == 'label' || $value == 'topic') { $valuetoshow = dol_escape_htmltag($valuetoshow); } if ($value == 'type_template') { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } if ($value == 'lang' && $valuetoshow) { @@ -828,29 +828,29 @@ if ($resql) { if ($valuetoshow > 0) { - $fuser=new User($db); + $fuser = new User($db); $fuser->fetch($valuetoshow); $valuetoshow = $fuser->getNomUrl(1); } } if ($value == 'private') { - $align="center"; - if ($valuetoshow) $valuetoshow=yn($valuetoshow); - else $valuetoshow=''; + $align = "center"; + if ($valuetoshow) $valuetoshow = yn($valuetoshow); + else $valuetoshow = ''; } if ($value == 'position') { - $align="center"; + $align = "center"; } if ($value == 'joinfiles') { - $align="center"; - if ($valuetoshow) $valuetoshow=1; - else $valuetoshow=''; + $align = "center"; + if ($valuetoshow) $valuetoshow = 1; + else $valuetoshow = ''; } - $class='tddict'; + $class = 'tddict'; // Show value for field if ($showfield) { @@ -861,17 +861,17 @@ if ($resql) } // Can an entry be erased or disabled ? - $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default - if (! $user->admin && $obj->fk_user != $user->id) + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (!$user->admin && $obj->fk_user != $user->id) { - $iserasable=0; - $canbedisabled=0; - $canbemodified=0; + $iserasable = 0; + $canbedisabled = 0; + $canbemodified = 0; } - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); if ($param) $url .= '&'.$param; - $url.='&'; + $url .= '&'; // Status / Active print ''; @@ -1000,20 +1000,20 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') elseif ($fieldlist[$field] == 'lang') { print ''; @@ -1022,7 +1022,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') elseif ($fieldlist[$field] == 'type_template') { print ''; } - elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; else { - $size=''; $class=''; $classtd=''; - if ($fieldlist[$field]=='code') $class='maxwidth100'; - if ($fieldlist[$field]=='label') $class='maxwidth100'; - if ($fieldlist[$field]=='private') { $class='maxwidth50'; $classtd='center'; } - if ($fieldlist[$field]=='position') { $class='maxwidth50'; $classtd='center'; } - if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent'; - if ($fieldlist[$field]=='topic') $class='quatrevingtpercent'; - if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; + $size = ''; $class = ''; $classtd = ''; + if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; + if ($fieldlist[$field] == 'label') $class = 'maxwidth100'; + if ($fieldlist[$field] == 'private') { $class = 'maxwidth50'; $classtd = 'center'; } + if ($fieldlist[$field] == 'position') { $class = 'maxwidth50'; $classtd = 'center'; } + if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent'; + if ($fieldlist[$field] == 'topic') $class = 'quatrevingtpercent'; + if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; - print ''; - if ($fieldlist[$field]=='private') + print ''; + if ($fieldlist[$field] == 'private') { if (empty($user->admin)) { @@ -1058,12 +1058,12 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') else { //print ''; - print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); + print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); } } else { - print ''; + print ''; } print ''; } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 9a0d8a459a2..5619c5a9713 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -36,34 +36,34 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","modulebuilder")); +$langs->loadLangs(array("errors", "admin", "modulebuilder")); -$mode=GETPOST('mode', 'alpha'); -if (empty($mode)) $mode='common'; -$action=GETPOST('action', 'alpha'); +$mode = GETPOST('mode', 'alpha'); +if (empty($mode)) $mode = 'common'; +$action = GETPOST('action', 'alpha'); //var_dump($_POST);exit; -$value=GETPOST('value', 'alpha'); -$page_y=GETPOST('page_y', 'int'); -$search_keyword=GETPOST('search_keyword', 'alpha'); -$search_status=GETPOST('search_status', 'alpha'); -$search_nature=GETPOST('search_nature', 'alpha'); -$search_version=GETPOST('search_version', 'alpha'); +$value = GETPOST('value', 'alpha'); +$page_y = GETPOST('page_y', 'int'); +$search_keyword = GETPOST('search_keyword', 'alpha'); +$search_status = GETPOST('search_status', 'alpha'); +$search_nature = GETPOST('search_nature', 'alpha'); +$search_version = GETPOST('search_version', 'alpha'); // For dolistore search $options = array(); $options['per_page'] = 20; -$options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int'):0) + 0); -$options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0); -$options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0); +$options['categorie'] = ((GETPOST('categorie', 'int') ?GETPOST('categorie', 'int') : 0) + 0); +$options['start'] = ((GETPOST('start', 'int') ?GETPOST('start', 'int') : 0) + 0); +$options['end'] = ((GETPOST('end', 'int') ?GETPOST('end', 'int') : 0) + 0); $options['search'] = GETPOST('search_keyword', 'alpha'); $dolistore = new Dolistore(false); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$familyinfo=array( +$familyinfo = array( 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")), 'crm'=>array('position'=>'006', 'label'=>$langs->trans("ModuleFamilyCrm")), 'srm'=>array('position'=>'007', 'label'=>$langs->trans("ModuleFamilySrm")), @@ -78,20 +78,20 @@ $familyinfo=array( 'other'=>array('position'=>'100', 'label'=>$langs->trans("ModuleFamilyOther")), ); -$param=''; -if (! GETPOST('buttonreset', 'alpha')) +$param = ''; +if (!GETPOST('buttonreset', 'alpha')) { - if ($search_keyword) $param.='&search_keyword='.urlencode($search_keyword); - if ($search_status && $search_status != '-1') $param.='&search_status='.urlencode($search_status); - if ($search_nature && $search_nature != '-1') $param.='&search_nature='.urlencode($search_nature); - if ($search_version && $search_version != '-1') $param.='&search_version='.urlencode($search_version); + if ($search_keyword) $param .= '&search_keyword='.urlencode($search_keyword); + if ($search_status && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); + if ($search_nature && $search_nature != '-1') $param .= '&search_nature='.urlencode($search_nature); + if ($search_version && $search_version != '-1') $param .= '&search_version='.urlencode($search_version); } -$dirins=DOL_DOCUMENT_ROOT.'/custom'; -$urldolibarrmodules='https://www.dolistore.com/'; +$dirins = DOL_DOCUMENT_ROOT.'/custom'; +$urldolibarrmodules = 'https://www.dolistore.com/'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('adminmodules','globaladmin')); +$hookmanager->initHooks(array('adminmodules', 'globaladmin')); /* @@ -100,27 +100,27 @@ $hookmanager->initHooks(array('adminmodules','globaladmin')); $formconfirm = ''; -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$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 (GETPOST('buttonreset', 'alpha')) { - $search_keyword=''; - $search_status=''; - $search_nature=''; - $search_version=''; + $search_keyword = ''; + $search_status = ''; + $search_nature = ''; + $search_version = ''; } -if ($action=='install') +if ($action == 'install') { - $error=0; + $error = 0; // $original_file should match format module_modulename-x.y[.z].zip - $original_file=basename($_FILES["fileinstall"]["name"]); - $newfile=$conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; + $original_file = basename($_FILES["fileinstall"]["name"]); + $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; - if (! $original_file) + if (!$original_file) { $langs->load("Error"); setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings'); @@ -128,13 +128,13 @@ if ($action=='install') } else { - if (! $error && ! preg_match('/\.zip$/i', $original_file)) + if (!$error && !preg_match('/\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors'); $error++; } - if (! $error && ! preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) + if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors'); @@ -148,7 +148,7 @@ if ($action=='install') } } - if (! $error) + if (!$error) { if ($original_file) { @@ -156,19 +156,19 @@ if ($action=='install') dol_mkdir($conf->admin->dir_temp.'/'.$original_file); } - $tmpdir=preg_replace('/\.zip$/i', '', $original_file).'.dir'; + $tmpdir = preg_replace('/\.zip$/i', '', $original_file).'.dir'; if ($tmpdir) { @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir); dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir); } - $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']); + $result = dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']); if ($result > 0) { - $result=dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir); + $result = dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir); - if (! empty($result['error'])) + if (!empty($result['error'])) { $langs->load("errors"); setEventMessages($langs->trans($result['error'], $original_file), null, 'errors'); @@ -177,23 +177,23 @@ if ($action=='install') else { // Now we move the dir of the module - $modulename=preg_replace('/module_/', '', $original_file); - $modulename=preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename); + $modulename = preg_replace('/module_/', '', $original_file); + $modulename = preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename); // Search dir $modulename - $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule + $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule //var_dump($modulenamedir); - if (! dol_is_dir($modulenamedir)) + if (!dol_is_dir($modulenamedir)) { - $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule + $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule //var_dump($modulenamedir); - if (! dol_is_dir($modulenamedir)) + if (!dol_is_dir($modulenamedir)) { setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'
'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors'); $error++; } } - if (! $error) + if (!$error) { // TODO Make more test } @@ -208,18 +208,18 @@ if ($action=='install') } $modulenamearrays[$modulename] = $modulename; - foreach($modulenamearrays as $modulenameval) { - if (strpos($modulenameval, '#') === 0) continue; // Discard comments - if (strpos($modulenameval, '//') === 0) continue; // Discard comments - if (! trim($modulenameval)) continue; + foreach ($modulenamearrays as $modulenameval) { + if (strpos($modulenameval, '#') === 0) continue; // Discard comments + if (strpos($modulenameval, '//') === 0) continue; // Discard comments + if (!trim($modulenameval)) continue; // Now we install the module - if (! $error) + if (!$error) { //var_dump($dirins); - @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file + @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the zip file dol_syslog("We copy now directory ".$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval." into target dir ".$dirins.'/'.$modulenameval); - $result=dolCopyDir($conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval, '0444', 1); + $result = dolCopyDir($conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval, $dirins.'/'.$modulenameval, '0444', 1); if ($result <= 0) { dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING); @@ -238,7 +238,7 @@ if ($action=='install') } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")), null, 'warnings'); } @@ -247,17 +247,17 @@ if ($action=='install') if ($action == 'set' && $user->admin) { $resarray = activateModule($value); - if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); + if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); else { //var_dump($resarray);exit; if ($resarray['nbperms'] > 0) { - $tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; - $resqltmp=$db->query($tmpsql); + $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; + $resqltmp = $db->query($tmpsql); if ($resqltmp) { - $obj=$db->fetch_object($resqltmp); + $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; if ($obj && $obj->nb > 1) { @@ -268,14 +268,14 @@ if ($action == 'set' && $user->admin) else dol_print_error($db); } } - header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; } elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { - $result=unActivateModule($value); + $result = unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; } @@ -291,51 +291,51 @@ $form = new Form($db); $morecss = array("/admin/dolistore/css/dolistore.css"); // 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)); +$dirins_ok = (dol_is_dir($dirins)); -$help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$help_url = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $help_url, '', '', '', $morejs, $morecss, 0, 0); // Search modules dirs $modulesdir = dolGetModulesDirs(); -$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']'); -$arrayofwarnings=array(); // Array of warning each module want to show when activated -$arrayofwarningsext=array(); // Array of warning each module want to show when we activate an external module +$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']'); +$arrayofwarnings = array(); // Array of warning each module want to show when activated +$arrayofwarningsext = array(); // Array of warning each module want to show when we activate an external module $filename = array(); $modules = array(); $orders = array(); $categ = array(); $dirmod = array(); -$i = 0; // is a sequencer of modules found -$j = 0; // j is module number. Automatically affected if module number not defined. -$modNameLoaded=array(); +$i = 0; // is a sequencer of modules found +$j = 0; // j is module number. Automatically affected if module number not defined. +$modNameLoaded = array(); foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)"); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); if ($modName) { - if (! empty($modNameLoaded[$modName])) // In cache of already loaded modules ? + if (!empty($modNameLoaded[$modName])) // In cache of already loaded modules ? { - $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; setEventMessages($mesg, null, 'warnings'); dol_syslog($mesg, LOG_ERR); continue; @@ -343,48 +343,48 @@ foreach ($modulesdir as $dir) try { - $res=include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. + $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. if (class_exists($modName)) { try { $objMod = new $modName($db); - $modNameLoaded[$modName]=$dir; - if (! $objMod->numero > 0 && $modName != 'modUser') + $modNameLoaded[$modName] = $dir; + if (!$objMod->numero > 0 && $modName != 'modUser') { dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); } $j = $objMod->numero; - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0; - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0; + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; // We discard modules according to property ->hidden - if (! empty($objMod->hidden)) $modulequalified=0; + if (!empty($objMod->hidden)) $modulequalified = 0; if ($modulequalified > 0) { - $publisher=dol_escape_htmltag($objMod->getPublisher()); - $external=($objMod->isCoreOrExternalModule() == 'external'); + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); if ($external) { if ($publisher) { - $arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher; + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; } else { - $arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers"); + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); } } ksort($arrayofnatures); // Define array $categ with categ with at least one qualified module - $filename[$i]= $modName; + $filename[$i] = $modName; $modules[$modName] = $objMod; // Gives the possibility to the module, to provide his own family info and position of this family @@ -395,20 +395,20 @@ foreach ($modulesdir as $dir) $familykey = $objMod->family; } - $moduleposition = ($objMod->module_position?$objMod->module_position:'50'); + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) { - $moduleposition = '80'; // External modules at end by default + $moduleposition = '80'; // External modules at end by default } // Add list of warnings to show into arrayofwarnings and arrayofwarningsext - if (! empty($objMod->warnings_activation)) + if (!empty($objMod->warnings_activation)) { - $arrayofwarnings[$modName]=$objMod->warnings_activation; + $arrayofwarnings[$modName] = $objMod->warnings_activation; } - if (! empty($objMod->warnings_activation_ext)) + if (!empty($objMod->warnings_activation_ext)) { - $arrayofwarningsext[$modName]=$objMod->warnings_activation_ext; + $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } $familyposition = $familyinfo[$familykey]['position']; @@ -419,20 +419,20 @@ foreach ($modulesdir as $dir) //$familyposition += 100; } - $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - $dirmod[$i] = $dir; + $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring]=1; + if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; + if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories + else $categ[$specialstring] = 1; $j++; $i++; } else dol_syslog("Module ".get_class($objMod)." not qualified"); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -442,7 +442,7 @@ foreach ($modulesdir as $dir) print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -459,13 +459,13 @@ foreach ($modulesdir as $dir) if ($action == 'reset_confirm' && $user->admin) { - if(!empty($modules[$value])) { - $objMod = $modules[$value]; + if (!empty($modules[$value])) { + $objMod = $modules[$value]; - if(!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); + if (!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles); $form = new Form($db); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1); } } @@ -476,17 +476,17 @@ asort($orders); //var_dump($categ); //var_dump($modules); -$nbofactivatedmodules=count($conf->modules); -$moreinfo=$langs->trans("TotalNumberOfActivatedModules", ($nbofactivatedmodules-1), count($modules)); +$nbofactivatedmodules = count($conf->modules); +$moreinfo = $langs->trans("TotalNumberOfActivatedModules", ($nbofactivatedmodules - 1), count($modules)); if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule")); print load_fiche_titre($langs->trans("ModulesSetup"), $moreinfo, 'title_setup'); // Start to show page -if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
\n"; -if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; -if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; -if ($mode=='develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; +if ($mode == 'common') print ''.$langs->trans("ModulesDesc")."
\n"; +if ($mode == 'marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; +if ($mode == 'deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +if ($mode == 'develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; $head = modules_prepare_head(); @@ -508,66 +508,66 @@ if ($mode == 'common') dol_fiche_head($head, $mode, '', -1); $moreforfilter = ''; - $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Keyword') . ': '; - $moreforfilter.= '
'; - $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1); - $moreforfilter.= '
'; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Keyword').': '; + $moreforfilter .= '
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Origin').': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1); + $moreforfilter .= '
'; + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); - if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated']=$langs->trans("Deprecated"); - if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental']=$langs->trans("Experimental"); - if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development']=$langs->trans("Development"); - $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Version') . ': '.$form->selectarray('search_version', $array_version, $search_version, 1); - $moreforfilter.= '
'; + if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated'] = $langs->trans("Deprecated"); + if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental'] = $langs->trans("Experimental"); + if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development'] = $langs->trans("Development"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Version').': '.$form->selectarray('search_version', $array_version, $search_version, 1); + $moreforfilter .= '
'; } - $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Status') . ': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1); - $moreforfilter.= '
'; - $moreforfilter.=' '; - $moreforfilter.='
'; - $moreforfilter.=''; - $moreforfilter.=' '; - $moreforfilter.=''; - $moreforfilter.= '
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Status').': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1); + $moreforfilter .= '
'; + $moreforfilter .= ' '; + $moreforfilter .= '
'; + $moreforfilter .= ''; + $moreforfilter .= ' '; + $moreforfilter .= ''; + $moreforfilter .= '
'; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; } - $moreforfilter=''; + $moreforfilter = ''; print '

'; - $object=new stdClass(); - $parameters=array(); - $reshook=$hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $object = new stdClass(); + $parameters = array(); + $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Show list of modules - $oldfamily=''; + $oldfamily = ''; foreach ($orders as $key => $value) { - $tab=explode('_', $value); - $familykey=$tab[1]; - $module_position=$tab[2]; + $tab = explode('_', $value); + $familykey = $tab[1]; + $module_position = $tab[2]; $modName = $filename[$key]; - $objMod = $modules[$modName]; + $objMod = $modules[$modName]; //print $objMod->name." - ".$key." - ".$objMod->version."
"; - if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab - if (! $objMod->getName()) + if (!$objMod->getName()) { dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING); continue; @@ -576,28 +576,28 @@ if ($mode == 'common') $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); // Check filters - $modulename=$objMod->getName(); - $moduletechnicalname=$objMod->name; - $moduledesc=$objMod->getDesc(); - $moduledesclong=$objMod->getDescLong(); - $moduleauthor=$objMod->getPublisher(); + $modulename = $objMod->getName(); + $moduletechnicalname = $objMod->name; + $moduledesc = $objMod->getDesc(); + $moduledesclong = $objMod->getDescLong(); + $moduleauthor = $objMod->getPublisher(); // We discard showing according to filters if ($search_keyword) { - $qualified=0; + $qualified = 0; if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename) || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname) || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc) || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong) || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor) - ) $qualified=1; - if (! $qualified) continue; + ) $qualified = 1; + if (!$qualified) continue; } if ($search_status) { if ($search_status == 'active' && empty($conf->global->$const_name)) continue; - if ($search_status == 'disabled' && ! empty($conf->global->$const_name)) continue; + if ($search_status == 'disabled' && !empty($conf->global->$const_name)) continue; } if ($search_nature) { @@ -605,24 +605,24 @@ if ($mode == 'common') if (preg_match('/^external_(.*)$/', $search_nature, $reg)) { //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher()); - $publisher=dol_escape_htmltag($objMod->getPublisher()); + $publisher = dol_escape_htmltag($objMod->getPublisher()); if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) continue; - if (! $reg[1] && ! empty($publisher)) continue; + if (!$reg[1] && !empty($publisher)) continue; } if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue; } if ($search_version) { if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue; - if ($objMod->version != 'development' && ($search_version == 'development')) continue; + if ($objMod->version != 'development' && ($search_version == 'development')) continue; if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue; - if (! preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue; + if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue; } // Load all lang files of module if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { - foreach($objMod->langfiles as $domain) + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } @@ -634,39 +634,39 @@ if ($mode == 'common') print '
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
'; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); print '
'; - $restrictid=array(); - if (! $user->admin) $restrictid=array($user->id); + $restrictid = array(); + if (!$user->admin) $restrictid = array($user->id); //var_dump($restrictid); print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($tmpfieldlist == 'topic') { - print '' . $form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . ' '; - print ''; + print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; } if ($tmpfieldlist == 'joinfiles') { - print '' . $form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . ' '; - print ''; + print ''.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; + print ''; } if ($tmpfieldlist == 'content') { - print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist) . '
'; + print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } print '
'; @@ -956,7 +956,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') global $conf, $langs, $user, $db; global $form; global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $elementList, $sourceList, $localtax_typeList; global $bc; $formadmin = new FormAdmin($db); @@ -975,24 +975,24 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { if ($context == 'add') // I am not admin and we show the add form { - print $user->getNomUrl(1); // Me - $forcedvalue=$user->id; + print $user->getNomUrl(1); // Me + $forcedvalue = $user->id; } else { - if ($obj && ! empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0) + if ($obj && !empty($obj->{$fieldlist[$field]}) && $obj->{$fieldlist[$field]} > 0) { - $fuser=new User($db); + $fuser = new User($db); $fuser->fetch($obj->{$fieldlist[$field]}); print $fuser->getNomUrl(1); - $forcedvalue=$fuser->id; + $forcedvalue = $fuser->id; } else { - $forcedvalue=$obj->{$fieldlist[$field]}; + $forcedvalue = $obj->{$fieldlist[$field]}; } } - $keyname=$fieldlist[$field]; + $keyname = $fieldlist[$field]; print ''; } print ''; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { - $selectedlang = GETPOSTISSET('langcode')?GETPOST('langcode', 'aZ09'):$langs->defaultlang; + $selectedlang = GETPOSTISSET('langcode') ?GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } else { - if (! empty($obj->{$fieldlist[$field]})) + if (!empty($obj->{$fieldlist[$field]})) { print $obj->{$fieldlist[$field]}.' - '.$langs->trans('Language_'.$obj->{$fieldlist[$field]}); } - $keyname=$fieldlist[$field]; - if ($keyname == 'lang') $keyname='langcode'; // Avoid conflict with lang param + $keyname = $fieldlist[$field]; + if ($keyname == 'lang') $keyname = 'langcode'; // Avoid conflict with lang param print ''; } print ''; - if ($context == 'edit' && ! empty($obj->{$fieldlist[$field]}) && ! in_array($obj->{$fieldlist[$field]}, array_keys($elementList))) + if ($context == 'edit' && !empty($obj->{$fieldlist[$field]}) && !in_array($obj->{$fieldlist[$field]}, array_keys($elementList))) { // Current tempalte type is an unknown type, so we must keep it as it is. print ''; @@ -1030,26 +1030,26 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } else { - print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150 maxwidth100onsmartphone'); + print $form->selectarray('type_template', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150 maxwidth100onsmartphone'); } print '

'; } - $familytext = empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label']; + $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label']; print load_fiche_titre($familytext, '', ''); print '
'; print ''."\n"; - $atleastoneforfamily=0; + $atleastoneforfamily = 0; } $atleastoneforfamily++; - if ($familykey!=$oldfamily) + if ($familykey != $oldfamily) { - $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label']; - $oldfamily=$familykey; + $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label']; + $oldfamily = $familykey; } // Version (with picto warning or not) - $version=$objMod->getVersion(0); - $versiontrans=''; - if (preg_match('/development/i', $version)) $versiontrans.=img_warning($langs->trans("Development"), 'style="float: left"'); - if (preg_match('/experimental/i', $version)) $versiontrans.=img_warning($langs->trans("Experimental"), 'style="float: left"'); - if (preg_match('/deprecated/i', $version)) $versiontrans.=img_warning($langs->trans("Deprecated"), 'style="float: left"'); - $versiontrans.=$objMod->getVersion(1); + $version = $objMod->getVersion(0); + $versiontrans = ''; + if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"'); + if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"'); + if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"'); + $versiontrans .= $objMod->getVersion(1); // Define imginfo - $imginfo="info"; + $imginfo = "info"; if ($objMod->isCoreOrExternalModule() == 'external') { - $imginfo="info_black"; + $imginfo = "info_black"; } print ''."\n"; @@ -674,10 +674,10 @@ if ($mode == 'common') // Picto + Name of module print ' \n"; // Activate/Disable and Setup (2 columns) - if (! empty($conf->global->$const_name)) // If module is already activated + if (!empty($conf->global->$const_name)) // If module is already activated { $disableSetup = 0; // Link enable/disabme print ''."\n"; // Link config - if (! empty($objMod->config_page_url) && !$disableSetup) + if (!empty($objMod->config_page_url) && !$disableSetup) { - $backtourlparam=''; - if ($search_keyword != '') $backtourlparam.=($backtourlparam?'&':'?').'search_keyword='.$search_keyword; // No urlencode here, done later - if ($search_nature > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_nature='.$search_nature; - if ($search_version > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_version='.$search_version; - if ($search_status > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_status='.$search_status; - $backtourl=$_SERVER["PHP_SELF"].$backtourlparam; + $backtourlparam = ''; + if ($search_keyword != '') $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.$search_keyword; // No urlencode here, done later + if ($search_nature > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.$search_nature; + if ($search_version > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.$search_version; + if ($search_status > -1) $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.$search_status; + $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; if (is_array($objMod->config_page_url)) { print ''; print ''."\n"; - $url='https://www.dolistore.com'; + $url = 'https://www.dolistore.com'; print ''; print ''; print ''; @@ -1052,29 +1052,29 @@ if ($mode == 'deploy') print $langs->trans("YouCanSubmitFile"); - $max=$conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp=@ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1; - if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024; - if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024; - if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024; - $maxphp2=@ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024; + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; + if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; + if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; + if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; + if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; + if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; + if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; if ($maxphp > 0) { - $maxmin=min($max, $maxphp); + $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } if ($maxphp2 > 0) { - $maxmin=min($max, $maxphp2); + $maxmin = min($max, $maxphp2); if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; @@ -1087,7 +1087,7 @@ if ($mode == 'deploy') print ''."\n"; // MAX_FILE_SIZE doit précéder le champ input de type file - print ''; + print ''; } print ' '; print ''; - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { if ($user->admin) { @@ -1131,11 +1131,11 @@ if ($mode == 'deploy') } } - if (! empty($result['return'])) + if (!empty($result['return'])) { print '
'; - foreach($result['return'] as $value) + foreach ($result['return'] as $value) { echo $value.'
'; } @@ -1167,7 +1167,7 @@ if ($mode == 'develop') print ''; print ''."\n"; - $url='https://partners.dolibarr.org'; + $url = 'https://partners.dolibarr.org'; print ''; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index ea8f839600d..1f811c325dd 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'users', 'other')); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); if (!$user->admin) accessforbidden(); @@ -43,16 +43,16 @@ if (!$user->admin) accessforbidden(); if ($action == 'add') { $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; - $sql.= " WHERE id = ".GETPOST("pid", 'int'); - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE id = ".GETPOST("pid", 'int'); + $sql .= " AND entity = ".$conf->entity; $db->query($sql); } if ($action == 'remove') { $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; - $sql.= " WHERE id = ".GETPOST('pid', 'int'); - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE id = ".GETPOST('pid', 'int'); + $sql .= " AND entity = ".$conf->entity; $db->query($sql); } @@ -61,7 +61,7 @@ if ($action == 'remove') * View */ -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("DefaultRights"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -78,10 +78,10 @@ foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; - $handle=@opendir(dol_osencode($dir)); + $handle = @opendir(dol_osencode($dir)); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { @@ -94,7 +94,7 @@ foreach ($modulesdir as $dir) // Load all lang files of module if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { - foreach($objMod->langfiles as $domain) + foreach ($objMod->langfiles as $domain) { $langs->load($domain); } @@ -102,8 +102,8 @@ foreach ($modulesdir as $dir) // Load all permissions if ($objMod->rights_class) { - $ret=$objMod->insert_permissions(0); - $modules[$objMod->rights_class]=$objMod; + $ret = $objMod->insert_permissions(0); + $modules[$objMod->rights_class] = $objMod; //print "modules[".$objMod->rights_class."]=$objMod;"; } } @@ -114,7 +114,7 @@ foreach ($modulesdir as $dir) $db->commit(); -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'default', $langs->trans("Security"), -1); @@ -127,42 +127,42 @@ print '
'; - $alttext=''; + $alttext = ''; //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version); //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin); - if (! empty($objMod->picto)) + if (!empty($objMod->picto)) { if (preg_match('/^\//i', $objMod->picto)) print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule"', 1); else print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule"'); @@ -703,13 +703,13 @@ if ($mode == 'common') // Version print ''; print $versiontrans; - if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){ + if (!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; if (!empty($objMod->url_last_version)) { $newversion = getURLContent($objMod->url_last_version); - if(isset($newversion['content'])){ + if (isset($newversion['content'])) { if (version_compare($newversion['content'], $versiontrans) > 0) { - print " ".$newversion['content'].""; + print " ".$newversion['content'].""; } } } @@ -717,38 +717,38 @@ if ($mode == 'common') print "'; - if (! empty($arrayofwarnings[$modName])) + if (!empty($arrayofwarnings[$modName])) { print ''."\n"; } - if (! empty($objMod->disabled)) + if (!empty($objMod->disabled)) { print $langs->trans("Disabled"); } - elseif (! empty($objMod->always_enabled) || ((! empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity!=1))) + elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) { if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) print $langs->trans("Used"); else { print img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium'); //print $langs->trans("Required"); } - if (! empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; + if (!empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; } else { - if(!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { - print 'warnings_unactivation[$mysoc->country_code].'&value=' . $modName . '&mode=' . $mode . $param . '">'; + if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { + print 'warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } @@ -756,22 +756,22 @@ if ($mode == 'common') print ''; - $i=0; + $i = 0; foreach ($objMod->config_page_url as $page) { - $urlpage=$page; + $urlpage = $page; if ($i++) { print ''.img_picto(ucfirst($page), "setup").''; @@ -781,13 +781,13 @@ if ($mode == 'common') { if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { - $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); - print ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); + print ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; } else { - $urltouse=$urlpage; - print ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + $urltouse = $urlpage; + print ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; } } } @@ -811,49 +811,49 @@ if ($mode == 'common') { // Link enable/disable print ''; - if (! empty($objMod->always_enabled)) + if (!empty($objMod->always_enabled)) { // Should never happened } - elseif (! empty($objMod->disabled)) + elseif (!empty($objMod->disabled)) { print $langs->trans("Disabled"); } else { // Module qualified for activation - $warningmessage=''; - if (! empty($arrayofwarnings[$modName])) + $warningmessage = ''; + if (!empty($arrayofwarnings[$modName])) { print ''."\n"; foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { - $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); } } - if ($objMod->isCoreOrExternalModule() == 'external' && ! empty($arrayofwarningsext)) + if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) { print ''."\n"; foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { - $keymodulelowercase=strtolower(preg_replace('/^mod/', '', $keymodule)); + $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule)); if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on { foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) { - $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); - $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName(); - if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name; - if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); + $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName(); + if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name; + if (!empty($objMod->editor_name)) $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); } } } } } print ''."\n"; - print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); @@ -898,7 +898,7 @@ if ($mode == 'marketplace') print '
'.$langs->trans("DoliStoreDesc").''.$url.'
'; print''; print '
'; // Show permissions lines $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; -$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; -$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" -$sql.= " AND entity = ".$conf->entity; -if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled -$sql.= " ORDER BY r.module, r.id"; +$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; +$sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" +$sql .= " AND entity = ".$conf->entity; +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled +$sql .= " ORDER BY r.module, r.id"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $oldmod = ""; + $num = $db->num_rows($result); + $i = 0; + $oldmod = ""; while ($i < $num) { $obj = $db->fetch_object($result); // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore - if (! $modules[$obj->module]) + if (!$modules[$obj->module]) { $i++; continue; } // Check if permission we found is inside a module definition. If not, we discard it. - $found=false; - foreach($modules[$obj->module]->rights as $key => $val) + $found = false; + foreach ($modules[$obj->module]->rights as $key => $val) { - $rights_class=$objMod->rights_class; + $rights_class = $objMod->rights_class; if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) { - $found=true; + $found = true; break; } } - if (! $found) + if (!$found) { $i++; continue; @@ -171,9 +171,9 @@ if ($result) // Break found, it's a new module to catch if ($oldmod <> $obj->module) { - $oldmod = $obj->module; - $objMod = $modules[$obj->module]; - $picto = ($objMod->picto?$objMod->picto:'generic'); + $oldmod = $obj->module; + $objMod = $modules[$obj->module]; + $picto = ($objMod->picto ? $objMod->picto : 'generic'); print ''; print ''; @@ -190,8 +190,8 @@ if ($result) print ' '; print ''; - $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); - print ''; + $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->libelle)); + print ''; print ''."\n"; @@ -319,22 +319,22 @@ foreach ($dirmodels as $reldir) } print ''; - $propal=new Propal($db); + $propal = new Propal($db); $propal->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $propal->type=0; - $nextval=$module->getNextValue($mysoc, $propal); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $propal->type = 0; + $nextval = $module->getNextValue($mysoc, $propal); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -362,14 +362,14 @@ print load_fiche_titre($langs->trans("ProposalsPDFModules"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -397,43 +397,43 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/propale".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { $var = !$var; print ''; print ""; print "\n"; print ''; */ -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print ''; print ''; print '\n"; @@ -251,11 +251,11 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -272,21 +272,21 @@ foreach ($dirmodels as $reldir) } print ''; - $reception=new Reception($db); + $reception = new Reception($db); $reception->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $reception); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $reception); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -312,19 +312,19 @@ print '
'.$langs->trans("Module").''.$perm_libelle. ''.$perm_libelle.''; if ($obj->bydefault == 1) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 4cde7aa8a20..a78add3cdc4 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -37,13 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "errors", "propal")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='propal'; +$type = 'propal'; /* * Actions @@ -51,16 +51,16 @@ $type='propal'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -$error=0; +$error = 0; if ($action == 'updateMask') { - $maskconstpropal=GETPOST('maskconstpropal', 'alpha'); - $maskpropal=GETPOST('maskpropal', 'alpha'); + $maskconstpropal = GETPOST('maskconstpropal', 'alpha'); + $maskpropal = GETPOST('maskpropal', 'alpha'); if ($maskconstpropal) $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -71,20 +71,20 @@ if ($action == 'updateMask') } elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $propal = new Propal($db); $propal->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -121,9 +121,9 @@ elseif ($action == 'setribchq') $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -137,9 +137,9 @@ elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') $draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -150,13 +150,13 @@ elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') } elseif ($action == 'set_PROPOSAL_FREE_TEXT') { - $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('PROPOSAL_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -169,9 +169,9 @@ elseif ($action == 'setdefaultduration') { $res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -185,9 +185,9 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -238,15 +238,15 @@ elseif ($action == 'setmod') * View */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader('', $langs->trans("PropalSetup")); //if ($mesg) print $mesg; -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup'); $head = propal_admin_prepare_head(); @@ -278,18 +278,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file; // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -300,9 +300,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -469,19 +469,19 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = $langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); //$htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); //$htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); print '
'; @@ -535,14 +535,14 @@ if (empty($conf->facture->enabled)) print '
".$langs->trans("SuggestPaymentByRIBOnAccount").""; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE clos = 0"; - $sql.= " AND courant = 1"; - $sql.= " AND entity IN (".getEntity('bank_account').")"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql .= " WHERE clos = 0"; + $sql .= " AND courant = 1"; + $sql .= " AND entity IN (".getEntity('bank_account').")"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -556,7 +556,7 @@ if (empty($conf->facture->enabled)) $row = $db->fetch_row($resql); print ''; $i++; @@ -580,15 +580,15 @@ if (empty($conf->facture->enabled)) print ""; print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='PROPOSAL_FREE_TEXT'; +$variablename = 'PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -670,7 +670,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index d705ee0e38d..f62834e3084 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -32,18 +32,18 @@ $langs->loadLangs(array("admin", "receptions", 'other')); if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); -$value=GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='reception'; +$type = 'reception'; /* * Actions */ -if (! empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) +if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { // This option should always be set to on when module is on. dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity); @@ -51,7 +51,7 @@ if (! empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RE if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { - $conf->global->RECEPTION_ADDON_NUMBER='mod_reception_beryl'; + $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl'; } @@ -63,9 +63,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst=GETPOST('maskconstreception', 'alpha'); - $maskvalue=GETPOST('maskreception', 'alpha'); - if (! empty($maskconst)) + $maskconst = GETPOST('maskconstreception', 'alpha'); + $maskvalue = GETPOST('maskreception', 'alpha'); + if (!empty($maskconst)) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (isset($res)) @@ -79,7 +79,7 @@ if ($action == 'updateMask') elseif ($action == 'set_param') { - $freetext=GETPOST('RECEPTION_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('RECEPTION_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "RECEPTION_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); if ($res <= 0) { @@ -87,7 +87,7 @@ elseif ($action == 'set_param') setEventMessages($langs->trans("Error"), null, 'errors'); } - $draft=GETPOST('RECEPTION_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('RECEPTION_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "RECEPTION_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); if ($res <= 0) { @@ -95,7 +95,7 @@ elseif ($action == 'set_param') setEventMessages($langs->trans("Error"), null, 'errors'); } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -103,20 +103,20 @@ elseif ($action == 'set_param') elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $exp = new Reception($db); $exp->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -191,13 +191,13 @@ elseif ($action == 'setmodel') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$form=new Form($db); +$form = new Form($db); llxHeader("", $langs->trans("ReceptionsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ReceptionsSetup"), $linkback, 'title_setup'); print '
'; $head = reception_admin_prepare_head(); @@ -228,11 +228,11 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 14) == 'mod_reception_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 14) == 'mod_reception_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; @@ -241,7 +241,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; print '
'.$module->nom."'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '

'; print load_fiche_titre($langs->trans("ReceptionsReceiptModel")); // Defini tableau def de modele invoice -$type="reception"; +$type = "reception"; $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -351,42 +351,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/reception".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -421,18 +421,18 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 783804a3d3f..12d9ded677c 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -434,20 +434,20 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); //$htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); //$htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); print ''; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index c0db15a48a7..d19e5d6fe92 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'members', 'users')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $extrafields = new ExtraFields($db); @@ -42,7 +42,7 @@ $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $value = GETPOST('value', 'alpha'); -$type='user'; +$type = 'user'; /* @@ -87,7 +87,7 @@ elseif ($action == 'setdoc') } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -101,7 +101,7 @@ elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -134,14 +134,14 @@ elseif ($action == 'sethideinactiveuser') $form = new Form($db); -$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; +$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; llxHeader('', $langs->trans("UsersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); -$head=user_admin_prepare_head(); +$head = user_admin_prepare_head(); dol_fiche_head($head, 'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); @@ -181,19 +181,19 @@ print ''; print '
'; -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -220,41 +220,41 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/user".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -290,17 +290,17 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.= '
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 75cdc514518..270d7dd6653 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -35,13 +35,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "members", "users")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $extrafields = new ExtraFields($db); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); -$type='group'; +$type = 'group'; /* * Action @@ -85,7 +85,7 @@ elseif ($action == 'setdoc') } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -99,7 +99,7 @@ elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -114,33 +114,33 @@ elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) * View */ -$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; +$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; llxHeader('', $langs->trans("UsersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); -$head=user_admin_prepare_head(); +$head = user_admin_prepare_head(); dol_fiche_head($head, 'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user'); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$form=new Form($db); +$form = new Form($db); // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -167,41 +167,41 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -236,18 +236,18 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index be1afb30bd4..5f3f3a165ef 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -27,21 +27,21 @@ require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; // Load translation files required by the page $langs->loadLangs(array('bookmarks', 'admin')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search // Security check -if (! $user->rights->bookmark->lire) { +if (!$user->rights->bookmark->lire) { restrictedArea($user, 'bookmarks'); } $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -54,7 +54,7 @@ if (!$sortorder) $sortorder = 'ASC'; $id = GETPOST("id", 'int'); -$object=new Bookmark($db); +$object = new Bookmark($db); $permissiontoread = $user->rights->bookmark->lire; $permissiontoadd = $user->rights->bookmark->write; @@ -67,7 +67,7 @@ $permissiontodelete = $user->rights->bookmark->delete; if ($action == 'delete') { - $res=$object->remove($id); + $res = $object->remove($id); if ($res > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -84,20 +84,20 @@ if ($action == 'delete') * View */ -$userstatic=new User($db); +$userstatic = new User($db); $title = $langs->trans("ListOfBookmarks"); llxHeader('', $title); $sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,"; -$sql.= " u.login, u.lastname, u.firstname"; -$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid"; -$sql.= " WHERE 1=1"; -$sql.= " AND b.entity IN (".getEntity('bookmark').")"; -if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)"; +$sql .= " u.login, u.lastname, u.firstname"; +$sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid"; +$sql .= " WHERE 1=1"; +$sql .= " AND b.entity IN (".getEntity('bookmark').")"; +if (!$user->admin) $sql .= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)"; -$sql.=$db->order($sortfield.", position", $sortorder); +$sql .= $db->order($sortfield.", position", $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -118,10 +118,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -131,22 +131,22 @@ else } $param = ""; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -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 ($optioncss != '') $param = '&optioncss='.urlencode($optioncss); -$moreforfilter=''; +$moreforfilter = ''; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'validate'=>$langs->trans("Validate"), //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -158,13 +158,13 @@ print ''; print ''; print ''; -$newcardbutton=''; -$newcardbutton.= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create', '', !empty($user->rights->bookmark->creer)); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create', '', !empty($user->rights->bookmark->creer)); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bookmark', 0, $newcardbutton, '', $limit); print '
'; -print ''."\n"; +print '
'."\n"; print ""; //print ""; @@ -193,13 +193,13 @@ while ($i < min($num, $limit)) print $object->getNomUrl(1); print ''; - $linkintern=0; - $title=$obj->title; - $link=$obj->url; + $linkintern = 0; + $title = $obj->title; + $link = $obj->url; // Title print "\n"; // Target @@ -222,8 +222,8 @@ while ($i < min($num, $limit)) print ''; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Availability - if (! empty($arrayfields['ava.rowid']['checked'])) + if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Amount HT - if (! empty($arrayfields['p.total_ht']['checked'])) + if (!empty($arrayfields['p.total_ht']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ht'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; $totalarray['val']['p.total_ht'] += $obj->total_ht; } // Amount VAT - if (! empty($arrayfields['p.total_vat']['checked'])) + if (!empty($arrayfields['p.total_vat']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_vat'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_vat'; $totalarray['val']['p.total_vat'] += $obj->total_vat; } // Amount TTC - if (! empty($arrayfields['p.total_ttc']['checked'])) + if (!empty($arrayfields['p.total_ttc']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ttc'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; $totalarray['val']['p.total_ttc'] += $obj->total_ttc; } // Amount invoiced - if(! empty($arrayfields['p.total_ht_invoiced']['checked'])) { + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { $totalInvoiced = 0; $p = new Propal($db); $TInvoiceData = $p->InvoiceArrayList($obj->rowid); - if(! empty($TInvoiceData)) { - foreach($TInvoiceData as $invoiceData) { + if (!empty($TInvoiceData)) { + foreach ($TInvoiceData as $invoiceData) { $invoice = new Facture($db); $invoice->fetch($invoiceData->facid); - if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; $totalInvoiced += $invoice->total_ht; } } print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ht_invoiced'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; $totalarray['val']['p.total_ht_invoiced'] += $obj->total_ht_invoiced; } // Amount invoiced - if(! empty($arrayfields['p.total_invoiced']['checked'])) { + if (!empty($arrayfields['p.total_invoiced']['checked'])) { $totalInvoiced = 0; $p = new Propal($db); $TInvoiceData = $p->InvoiceArrayList($obj->rowid); - if(! empty($TInvoiceData)) { - foreach($TInvoiceData as $invoiceData) { + if (!empty($TInvoiceData)) { + foreach ($TInvoiceData as $invoiceData) { $invoice = new Facture($db); $invoice->fetch($invoiceData->facid); - if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; $totalInvoiced += $invoice->total_ttc; } } print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_invoiced'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; $totalarray['val']['p.total_invoiced'] += $obj->total_invoiced; } - $userstatic->id=$obj->fk_user_author; - $userstatic->login=$obj->login; + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; // Author - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['sale_representative']['checked'])) + if (!empty($arrayfields['sale_representative']['checked'])) { // Sales representatives print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Order date - if (! empty($arrayfields['c.date_commande']['checked'])) + if (!empty($arrayfields['c.date_commande']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Plannned date of delivery - if (! empty($arrayfields['c.date_delivery']['checked'])) + if (!empty($arrayfields['c.date_delivery']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Amount HT - if (! empty($arrayfields['c.total_ht']['checked'])) + if (!empty($arrayfields['c.total_ht']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_ht'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; $totalarray['val']['c.total_ht'] += $obj->total_ht; } // Amount VAT - if (! empty($arrayfields['c.total_vat']['checked'])) + if (!empty($arrayfields['c.total_vat']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_tva'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; $totalarray['val']['c.total_tva'] += $obj->total_tva; } // Amount TTC - if (! empty($arrayfields['c.total_ttc']['checked'])) + if (!empty($arrayfields['c.total_ttc']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_ttc'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; $totalarray['val']['c.total_ttc'] += $obj->total_ttc; } // 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); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['c.datec']['checked'])) + if (!empty($arrayfields['c.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['c.tms']['checked'])) + if (!empty($arrayfields['c.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date cloture - if (! empty($arrayfields['c.date_cloture']['checked'])) + if (!empty($arrayfields['c.date_cloture']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['c.fk_statut']['checked'])) + if (!empty($arrayfields['c.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Billed - if (! empty($arrayfields['c.facture']['checked'])) + if (!empty($arrayfields['c.facture']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; - $total+=$obj->total_ht; - $subtotal+=$obj->total_ht; + $total += $obj->total_ht; + $subtotal += $obj->total_ht; $i++; } diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 9b6e129d0a5..c9c48fd9b93 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacementstats.class // Load translation files required by the page $langs->loadLangs(array('trips', 'companies')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid', 'int'); if ($userid < 0) $userid=0; -$socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0; +$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0; +$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; $id = GETPOST('id', 'int'); // Security check @@ -43,51 +43,51 @@ if ($user->socid > 0) $action = ''; $socid = $user->socid; } -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); // Other security check $childids = $user->getAllChildIds(); -$childids[]=$user->id; +$childids[] = $user->id; if ($userid > 0) { - if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous) && ! in_array($userid, $childids)) + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous) && !in_array($userid, $childids)) { accessforbidden(); exit; } } -$nowyear=strftime("%Y", dol_now()); -$year = GETPOST('year')>0?GETPOST('year'):$nowyear; +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; //$startyear=$year-2; -$startyear=$year-1; -$endyear=$year; +$startyear = $year - 1; +$endyear = $year; -$mode=GETPOST("mode")?GETPOST("mode"):'customer'; +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; /* * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); -$title=$langs->trans("TripsAndExpensesStatistics"); -$dir=$conf->deplacement->dir_temp; +$title = $langs->trans("TripsAndExpensesStatistics"); +$dir = $conf->deplacement->dir_temp; print load_fiche_titre($title, $mesg); dol_mkdir($dir); -$useridtofilter=$userid; // Filter from parameters +$useridtofilter = $userid; // Filter from parameters if (empty($useridtofilter)) { - $useridtofilter=$childids; - if (! empty($user->rights->deplacement->readall) || ! empty($user->rights->deplacement->lire_tous)) $useridtofilter=0; + $useridtofilter = $childids; + if (!empty($user->rights->deplacement->readall) || !empty($user->rights->deplacement->lire_tous)) $useridtofilter = 0; } $stats = new DeplacementStats($db, $socid, $useridtofilter); @@ -104,13 +104,13 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px1->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px1->SetLegend($legend); @@ -120,7 +120,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("Number")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -136,13 +136,13 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats& $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px2->SetData($data); - $i=$startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px2->SetLegend($legend); @@ -153,7 +153,7 @@ if (! $mesg) $px2->SetYLabel($langs->trans("Amount")); $px2->SetShading(3); $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountTotal")); $px2->draw($filenameamount, $fileurlamount); @@ -177,13 +177,13 @@ else $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px3->SetData($data); - $i = $startyear;$legend=array(); + $i = $startyear; $legend = array(); while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px3->SetLegend($legend); @@ -194,7 +194,7 @@ if (! $mesg) $px3->SetHeight($HEIGHT); $px3->SetShading(3); $px3->SetHorizTickIncrement(1); - $px3->mode='depth'; + $px3->mode = 'depth'; $px3->SetTitle($langs->trans("AmountAverage")); $px3->draw($filename_avg, $fileurl_avg); @@ -203,16 +203,16 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + $arrayyears[$val['year']] = $val['year']; } -if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; -$h=0; +$h = 0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; @@ -232,18 +232,18 @@ print '
 "; - $linkintern=1; + $linkintern = 1; if ($linkintern) print "url."\">"; print $title; if ($linkintern) print ""; @@ -207,9 +207,9 @@ while ($i < min($num, $limit)) // Url print ''; - if (! $linkintern) print 'target?' target="newlink"':'').'>'; + if (!$linkintern) print 'target ? ' target="newlink"' : '').'>'; print $link; - if (! $linkintern) print ''; + if (!$linkintern) print ''; print "'; if ($obj->fk_user) { - $userstatic->id=$obj->fk_user; - $userstatic->lastname=$obj->login; + $userstatic->id = $obj->fk_user; + $userstatic->lastname = $obj->login; print $userstatic->getNomUrl(1); } else diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 43e28b34ca3..5208e56df5e 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; $filter = GETPOST("filter", 'alpha', 3); $filtert = GETPOST("filtert", "int", 3); @@ -51,90 +51,90 @@ $showbirthday = 0; // If not choice done on calendar owner, we filter on user. if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { - $filtert=$user->id; + $filtert = $user->id; } $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", "int"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="a.datec"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "a.datec"; // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($socid < 0) $socid=''; +if ($socid < 0) $socid = ''; -$canedit=1; -if (! $user->rights->agenda->myactions->read) accessforbidden(); -if (! $user->rights->agenda->allactions->read) $canedit=0; -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me +$canedit = 1; +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert=$user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); -$action='show_pertype'; -$resourceid=GETPOST("resourceid", "int"); -$year=GETPOST("year", "int")?GETPOST("year", "int"):date("Y"); -$month=GETPOST("month", "int")?GETPOST("month", "int"):date("m"); -$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); -$day=GETPOST("day", "int")?GETPOST("day", "int"):date("d"); -$pid=GETPOST("projectid", "int", 3); -$status=GETPOST("status", 'alpha'); -$type=GETPOST("type", 'alpha'); -$maxprint=((GETPOST("maxprint", 'int')!='')?GETPOST("maxprint", 'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$action = 'show_pertype'; +$resourceid = GETPOST("resourceid", "int"); +$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); +$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); +$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); +$pid = GETPOST("projectid", "int", 3); +$status = GETPOST("status", 'alpha'); +$type = GETPOST("type", 'alpha'); +$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode", "alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); if ($dateselect > 0) { - $day=GETPOST('dateselectday', 'int'); - $month=GETPOST('dateselectmonth', 'int'); - $year=GETPOST('dateselectyear', 'int'); + $day = GETPOST('dateselectday', 'int'); + $month = GETPOST('dateselectmonth', 'int'); + $year = GETPOST('dateselectyear', 'int'); } -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; -$tmparray=explode('-', $tmp); -$begin_h = GETPOST('begin_h', 'int')!=''?GETPOST('begin_h', 'int'):($tmparray[0] != '' ? $tmparray[0] : 9); -$end_h = GETPOST('end_h', 'int')?GETPOST('end_h', 'int'):($tmparray[1] != '' ? $tmparray[1] : 18); +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; +$tmparray = explode('-', $tmp); +$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); +$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h <= $begin_h) $end_h = $begin_h + 1; -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; -$tmparray=explode('-', $tmp); +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; +$tmparray = explode('-', $tmp); $begin_d = 1; $end_d = 53; -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action='show_month'; $day=''; +if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week -if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action='show_day'; $day=($day?$day:date("d")); +if (GETPOST('viewday', 'alpha') || $action == 'show_day') { + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day -if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { - $action='show_year'; +if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { + $action = 'show_year'; } // View by year // Load translation files required by the page @@ -148,11 +148,11 @@ $hookmanager->initHooks(array('agenda')); * Actions */ -if ($action =='delete_action') +if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); - $result=$event->delete(); + $result = $event->delete(); } @@ -161,21 +161,21 @@ if ($action =='delete_action') * View */ -$form=new Form($db); -$companystatic=new Societe($db); +$form = new Form($db); +$companystatic = new Societe($db); -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); -$now=dol_now(); -$nowarray=dol_getdate($now); -$nowyear=$nowarray['year']; -$nowmonth=$nowarray['mon']; -$nowday=$nowarray['mday']; +$now = dol_now(); +$nowarray = dol_getdate($now); +$nowyear = $nowarray['year']; +$nowmonth = $nowarray['mon']; +$nowday = $nowarray['mday']; // Define list of all external calendars (global setup) -$listofextcals=array(); +$listofextcals = array(); $prev = dol_get_first_day($year, $month); $first_day = 1; @@ -196,30 +196,30 @@ $tmpday = $first_day; //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; -$title=$langs->trans("DoneAndToDoActions"); -if ($status == 'done') $title=$langs->trans("DoneActions"); -if ($status == 'todo') $title=$langs->trans("ToDoActions"); +$title = $langs->trans("DoneAndToDoActions"); +if ($status == 'done') $title = $langs->trans("DoneActions"); +if ($status == 'todo') $title = $langs->trans("ToDoActions"); -$param=''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; -if ($resourceid > 0) $param.="&resourceid=".$resourceid; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; -if ($filter) $param.="&filter=".$filter; -if ($filtert) $param.="&filtert=".$filtert; -if ($usergroup) $param.="&usergroup=".$usergroup; -if ($socid) $param.="&socid=".$socid; -if ($showbirthday) $param.="&showbirthday=1"; -if ($pid) $param.="&projectid=".$pid; -if ($type) $param.="&type=".$type; -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param.='&action='.$action; -$param.="&maxprint=".$maxprint; +$param = ''; +if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode; +if ($resourceid > 0) $param .= "&resourceid=".$resourceid; +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status; +if ($filter) $param .= "&filter=".$filter; +if ($filtert) $param .= "&filtert=".$filtert; +if ($usergroup) $param .= "&usergroup=".$usergroup; +if ($socid) $param .= "&socid=".$socid; +if ($showbirthday) $param .= "&showbirthday=1"; +if ($pid) $param .= "&projectid=".$pid; +if ($type) $param .= "&type=".$type; +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action; +$param .= "&maxprint=".$maxprint; $prev = dol_get_first_day($year, 1); $prev_year = $year - 1; $prev_month = $month; $prev_day = $day; $first_day = 1; -$first_month= 1; +$first_month = 1; $first_year = $year; $week = $prev['week']; @@ -231,8 +231,8 @@ $next_month = $month; $next_day = $day; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow=dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; //print dol_print_date($firstdaytoshow,'dayhour'); //print dol_print_date($lastdaytoshow,'dayhour'); @@ -241,42 +241,42 @@ $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; -$nav ="".img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")." \n"; -$nav.="".img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$picto='calendarweek'; +$nav = "".img_previous($langs->trans("Previous"))."\n"; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")." \n"; +$nav .= "".img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$picto = 'calendarweek'; -$nav.='   '; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; +$nav .= '   '; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; -$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav.=' '; -$nav.=''; +$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); +$nav .= ' '; +$nav .= ''; // Must be after the nav definition -$param.='&year='.$year.'&month='.$month.($day?'&day='.$day:''); +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); //print 'x'.$param; -$tabactive='cardpertype'; +$tabactive = 'cardpertype'; -$paramnoaction=preg_replace('/action=[a-z_]+/', '', $param); +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $head = calendars_prepare_head($paramnoaction); @@ -284,51 +284,51 @@ dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); dol_fiche_end(); -$showextcals=$listofextcals; +$showextcals = $listofextcals; // Legend if ($conf->use_javascript_ajax) { - $s=''; - $s.='' . "\n"; - if (! empty($conf->use_javascript_ajax)) + $s .= '});'."\n"; + $s .= ''."\n"; + if (!empty($conf->use_javascript_ajax)) { - $s.='
' . $langs->trans("LocalAgenda").'  
'; + $s .= '
'.$langs->trans("LocalAgenda").'  
'; if (is_array($showextcals) && count($showextcals) > 0) { foreach ($showextcals as $val) { $htmlname = md5($val['name']); - $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s .= ''."\n"; + $s .= '
'.$val ['name'].'  
'; } } //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters=array(); $object=null; - $reshook=$hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { - $s.= $hookmanager->resPrint; + $s .= $hookmanager->resPrint; } elseif ($reshook > 1) { @@ -339,168 +339,168 @@ if ($conf->use_javascript_ajax) -$link=''; +$link = ''; print load_fiche_titre($s, $link.'     '.$nav, ''); // Get event in an array -$eventarray=array(); +$eventarray = array(); $sql = 'SELECT'; -if ($usergroup > 0) $sql.=" DISTINCT"; -$sql.= ' a.id, a.label,'; -$sql.= ' a.datep,'; -$sql.= ' a.datep2,'; -$sql.= ' a.percent,'; -$sql.= ' a.fk_user_author,a.fk_user_action,'; -$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; -$sql.= ' ca.code, ca.color'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +if ($usergroup > 0) $sql .= " DISTINCT"; +$sql .= ' a.id, a.label,'; +$sql .= ' a.datep,'; +$sql .= ' a.datep2,'; +$sql .= ' a.percent,'; +$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; +$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; +$sql .= ' ca.code, ca.color'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; // We must filter on resource table -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -$sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +$sql .= ' WHERE a.fk_action = ca.id'; +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (! empty($actioncode)) +if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } } -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { // To limit array - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year)-(60*60*24*7))."'"; // Start 7 days before - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year)+(60*60*24*7))."')"; // End 7 days after - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year)+(60*60*24*7))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year)+(60*60*24*7))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= ')'; } -if ($type) $sql.= " AND ca.id = ".$type; -if ($status == '0') { $sql.= " AND a.percent = 0"; } -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($type) $sql .= " AND ca.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql.= " AND ("; - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; - $sql.= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date -$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action +$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action //print $sql; dol_syslog("comm/action/index.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') { $i++; continue; } - $datep=$db->jdate($obj->datep); - $datep2=$db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); // Create a new object action - $event=new ActionComm($db); - $event->id=$obj->id; - $event->datep=$datep; // datep and datef are GMT date - $event->datef=$datep2; - $event->type_code=$obj->code; - $event->type_color=$obj->color; - $event->label=$obj->label; - $event->percentage=$obj->percent; - $event->authorid=$obj->fk_user_author; // user id of creator - $event->userownerid=$obj->fk_user_action; // user id of owner - $event->priority=$obj->priority; - $event->fulldayevent=$obj->fulldayevent; - $event->location=$obj->location; - $event->transparency=$obj->transparency; + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project=$obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid=$obj->fk_soc; - $event->contactid=$obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contactid = $obj->fk_contact; - $event->fk_element=$obj->fk_element; - $event->elementtype=$obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. if ($event->percentage <= 0) { - $event->date_start_in_calendar=$datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; - else $event->date_end_in_calendar=$datep; + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; } else { - $event->date_start_in_calendar=$datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; - else $event->date_end_in_calendar=$datep; + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; } // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { - $event->ponctuel=1; + $event->ponctuel = 1; } // Check values @@ -513,29 +513,29 @@ if ($resql) else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; - $event->fetch_userassigned(); // This load $event->userassigned + $event->fetch_userassigned(); // This load $event->userassigned - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][]=$event; + $eventarray[$daykey][] = $event; $j++; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; } while ($loop); @@ -550,9 +550,9 @@ else dol_print_error($db); } -$maxnbofchar=18; -$cachethirdparties=array(); -$cachecontacts=array(); +$maxnbofchar = 18; +$cachethirdparties = array(); +$cachecontacts = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -560,24 +560,24 @@ if (is_readable($color_file)) { include_once $color_file; } -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); -$newparam=$param; // newparam is for birthday links -$newparam=preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done -$newparam=preg_replace('/action=show_month&?/i', '', $newparam); -$newparam=preg_replace('/action=show_week&?/i', '', $newparam); -$newparam=preg_replace('/day=[0-9]+&?/i', '', $newparam); -$newparam=preg_replace('/month=[0-9]+&?/i', '', $newparam); -$newparam=preg_replace('/year=[0-9]+&?/i', '', $newparam); -$newparam=preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); -$newparam=preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter -$newparam.='&viewweek=1'; +$newparam = $param; // newparam is for birthday links +$newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done +$newparam = preg_replace('/action=show_month&?/i', '', $newparam); +$newparam = preg_replace('/action=show_week&?/i', '', $newparam); +$newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); +$newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); +$newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); +$newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); +$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter +$newparam .= '&viewweek=1'; echo '
'; echo ''; echo ''; -echo '' ; +echo ''; echo '
'; @@ -590,7 +590,7 @@ echo ''; echo ''; echo ''; -$i=0; // 0 = sunday, +$i = 0; // 0 = sunday, echo '\n"; echo ''; echo ''; -$i=0; +$i = 0; for ($h = $begin_d; $h < $end_d; $h++) { echo '\n"; echo "\n"; -$typeofevents=array(); +$typeofevents = array(); // Load array of colors by type -$colorsbytype=array(); -$labelbytype=array(); -$sql="SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; -$resql=$db->query($sql); +$colorsbytype = array(); +$labelbytype = array(); +$sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; +$resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { - $colorsbytype[$obj->code]=$obj->color; - $labelbytype[$obj->code]=$obj->label; + $colorsbytype[$obj->code] = $obj->color; + $labelbytype[$obj->code] = $obj->label; } // Loop on each user to show calendar -$todayarray=dol_getdate($now, 'fast'); +$todayarray = dol_getdate($now, 'fast'); $sav = $tmpday; $showheader = true; $var = false; foreach ($typeofevents as $typeofevent) { - $var = ! $var; + $var = !$var; echo ""; - echo ''; + echo ''; $tmpday = $sav; // Lopp on each day of week @@ -653,11 +653,11 @@ foreach ($typeofevents as $typeofevent) $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month'; - $today=0; - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; - if ($today) $style='cal_today_peruser'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today_peruser'; show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); @@ -670,16 +670,16 @@ foreach ($typeofevents as $typeofevent) echo "
'; echo $langs->trans("Year"); print "
"; @@ -600,7 +600,7 @@ echo "
'; @@ -611,29 +611,29 @@ echo "
' . $username->getNomUrl(1). ''.$username->getNomUrl(1).'
\n"; -if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { $langs->load("commercial"); print '
'.$langs->trans("Legend").':
'; - foreach($colorsbytype as $code => $color) + foreach ($colorsbytype as $code => $color) { if ($color) { - print '
 
'; - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; + print '
 
'; + print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code]; //print $code; print '
'; } @@ -761,20 +761,20 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s { global $db; global $user, $conf, $langs, $hookmanager, $action; - global $filter, $filtert, $status, $actioncode; // Filters used into search form - global $theme_datacolor; // Array with a list of different we can use (come from theme) + global $filter, $filtert, $status, $actioncode; // Filters used into search form + global $theme_datacolor; // Array with a list of different we can use (come from theme) global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused; global $begin_h, $end_h; - $cases1 = array(); // Color first half hour + $cases1 = array(); // Color first half hour $cases2 = array(); // Color second half hour $curtime = dol_mktime(0, 0, 0, $month, $day, $year); - $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); - $ymd=sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + $i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - $nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... + $nextindextouse = count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... //if ($username->id && $day==1) var_dump($eventarray); // We are in a particular day for $username, now we scan all events @@ -785,70 +785,70 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $jour = date('d', $daykey); //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."
\n"; - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? + if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? { // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { //var_dump($event); - $keysofuserassigned=array_keys($event->userassigned); - if (! in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show + $keysofuserassigned = array_keys($event->userassigned); + if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show - $parameters=array(); - $reshook=$hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); // Define $color (Hex string like '0088FF') and $cssclass of event - $color=-1; $cssclass=''; $colorindex=-1; + $color = -1; $cssclass = ''; $colorindex = -1; if (in_array($user->id, $keysofuserassigned)) { - $nummytasks++; $cssclass='family_mytasks'; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; + $nummytasks++; $cssclass = 'family_mytasks'; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; } elseif ($event->type_code == 'ICALEVENT') { $numical++; - if (! empty($event->icalname)) + if (!empty($event->icalname)) { - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } $numicals[dol_string_nospecial($event->icalname)]++; } - $color=$event->icalcolor; - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); + $color = $event->icalcolor; + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); } elseif ($event->type_code == 'BIRTHDAY') { - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { - $numother++; $cssclass='family_other'; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; + $numother++; $cssclass = 'family_other'; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; } if ($color < 0) // Color was not forced. Set color according to color index. { // Define color index if not yet defined - $idusertouse=($event->userownerid?$event->userownerid:0); + $idusertouse = ($event->userownerid ? $event->userownerid : 0); if (isset($colorindexused[$idusertouse])) { - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { - $colorindex=$nextindextouse; - $colorindexused[$idusertouse]=$colorindex; - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color } // Define color - $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; @@ -861,193 +861,193 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s { $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0); $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0); - $c = dol_mktime((int) $h+1, 0, 0, $month, $day, $year, false, 0); + $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0); - $dateendtouse=$event->date_end_in_calendar; - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; + $dateendtouse = $event->date_end_in_calendar; + if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'
'; if ($event->date_start_in_calendar < $b && $dateendtouse > $a) { - $busy=$event->transparency; - $cases1[$h][$event->id]['busy']=$busy; - $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar, 'dayhour'); + $busy = $event->transparency; + $cases1[$h][$event->id]['busy'] = $busy; + $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) { - $tmpa=dol_getdate($event->date_start_in_calendar, true); - $tmpb=dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); } - $cases1[$h][$event->id]['string'].=' - '.$event->label; - $cases1[$h][$event->id]['typecode']=$event->type_code; - $cases1[$h][$event->id]['color']=$color; + $cases1[$h][$event->id]['string'] .= ' - '.$event->label; + $cases1[$h][$event->id]['typecode'] = $event->type_code; + $cases1[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) { if (empty($cacheprojects[$event->fk_project])) { - $tmpproj=new Project($db); + $tmpproj = new Project($db); $tmpproj->fetch($event->fk_project); - $cacheprojects[$event->fk_project]=$tmpproj; + $cacheprojects[$event->fk_project] = $tmpproj; } - $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; + $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; } if ($event->socid > 0) { if (empty($cachethirdparties[$event->socid])) { - $tmpthirdparty=new Societe($db); + $tmpthirdparty = new Societe($db); $tmpthirdparty->fetch($event->socid); - $cachethirdparties[$event->socid]=$tmpthirdparty; + $cachethirdparties[$event->socid] = $tmpthirdparty; } - $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; + $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; } if ($event->contactid > 0) { if (empty($cachecontacts[$event->contactid])) { - $tmpcontact=new Contact($db); + $tmpcontact = new Contact($db); $tmpcontact->fetch($event->contactid); - $cachecontacts[$event->contactid]=$tmpcontact; + $cachecontacts[$event->contactid] = $tmpcontact; } - $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); + $cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); } } if ($event->date_start_in_calendar < $c && $dateendtouse > $b) { - $busy=$event->transparency; - $cases2[$h][$event->id]['busy']=$busy; - $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar, 'dayhour'); + $busy = $event->transparency; + $cases2[$h][$event->id]['busy'] = $busy; + $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) { - $tmpa=dol_getdate($event->date_start_in_calendar, true); - $tmpb=dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); } - $cases2[$h][$event->id]['string'].=' - '.$event->label; - $cases2[$h][$event->id]['typecode']=$event->type_code; - $cases2[$h][$event->id]['color']=$color; + $cases2[$h][$event->id]['string'] .= ' - '.$event->label; + $cases2[$h][$event->id]['typecode'] = $event->type_code; + $cases2[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) { if (empty($cacheprojects[$event->fk_project])) { - $tmpproj=new Project($db); + $tmpproj = new Project($db); $tmpproj->fetch($event->fk_project); - $cacheprojects[$event->fk_project]=$tmpproj; + $cacheprojects[$event->fk_project] = $tmpproj; } - $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; + $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; } if ($event->socid > 0) { if (empty($cachethirdparties[$event->socid])) { - $tmpthirdparty=new Societe($db); + $tmpthirdparty = new Societe($db); $tmpthirdparty->fetch($event->socid); - $cachethirdparties[$event->socid]=$tmpthirdparty; + $cachethirdparties[$event->socid] = $tmpthirdparty; } - $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; + $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; } if ($event->contactid > 0) { if (empty($cachecontacts[$event->contactid])) { - $tmpcontact=new Contact($db); + $tmpcontact = new Contact($db); $tmpcontact->fetch($event->contactid); - $cachecontacts[$event->contactid]=$tmpcontact; + $cachecontacts[$event->contactid] = $tmpcontact; } - $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); + $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); } } } else { - $busy=$event->transparency; - $cases1[$h][$event->id]['busy']=$busy; - $cases2[$h][$event->id]['busy']=$busy; - $cases1[$h][$event->id]['string']=$event->label; - $cases2[$h][$event->id]['string']=$event->label; - $cases1[$h][$event->id]['typecode']=$event->type_code; - $cases2[$h][$event->id]['typecode']=$event->type_code; - $cases1[$h][$event->id]['color']=$color; - $cases2[$h][$event->id]['color']=$color; + $busy = $event->transparency; + $cases1[$h][$event->id]['busy'] = $busy; + $cases2[$h][$event->id]['busy'] = $busy; + $cases1[$h][$event->id]['string'] = $event->label; + $cases2[$h][$event->id]['string'] = $event->label; + $cases1[$h][$event->id]['typecode'] = $event->type_code; + $cases2[$h][$event->id]['typecode'] = $event->type_code; + $cases1[$h][$event->id]['color'] = $color; + $cases2[$h][$event->id]['color'] = $color; } } $i++; } - break; // We found the date we were looking for. No need to search anymore. + break; // We found the date we were looking for. No need to search anymore. } } // Now output $casesX for ($h = $begin_h; $h < $end_h; $h++) { - $color1='';$color2=''; - $style1='';$style2=''; - $string1=' ';$string2=' '; - $title1='';$title2=''; + $color1 = ''; $color2 = ''; + $style1 = ''; $style2 = ''; + $string1 = ' '; $string2 = ' '; + $title1 = ''; $title2 = ''; if (isset($cases1[$h]) && $cases1[$h] != '') { //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); - $string1=' '; - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; - else $style1='peruser_busy'; - foreach($cases1[$h] as $id => $ev) + if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); + $string1 = ' '; + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; + else $style1 = 'peruser_busy'; + foreach ($cases1[$h] as $id => $ev) { - if ($ev['busy']) $style1='peruser_busy'; + if ($ev['busy']) $style1 = 'peruser_busy'; } } if (isset($cases2[$h]) && $cases2[$h] != '') { //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); - $string2=' '; - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; - else $style2='peruser_busy'; - foreach($cases2[$h] as $id => $ev) + if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); + $string2 = ' '; + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; + else $style2 = 'peruser_busy'; + foreach ($cases2[$h] as $id => $ev) { - if ($ev['busy']) $style2='peruser_busy'; + if ($ev['busy']) $style2 = 'peruser_busy'; } } - $ids1='';$ids2=''; - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',', array_keys($cases1[$h])); - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',', array_keys($cases2[$h])); + $ids1 = ''; $ids2 = ''; + if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); + if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); - if ($h == $begin_h) echo '
'; - else echo ''; + if ($h == $begin_h) echo ''; + else echo ''; if (count($cases1[$h]) == 1) // only 1 event { $output = array_slice($cases1[$h], 0, 1); - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); + if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color1 = $output[0]['color']; } elseif (count($cases1[$h]) > 1) { - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); - $color1='222222'; + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); + $color1 = '222222'; } if (count($cases2[$h]) == 1) // only 1 event { $output = array_slice($cases2[$h], 0, 1); - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); + if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; if ($output[0]['color']) $color2 = $output[0]['color']; } elseif (count($cases2[$h]) > 1) { - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); - $color2='222222'; + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); + $color2 = '222222'; } print ''; - print ''; print '
'; + print '
'; print $string1; - print ''; + print ''; print $string2; print '
'; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 460c691329e..a744578b392 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -247,7 +247,7 @@ if ($object->fetch($id) >= 0) print '
'.$langs->trans("MailFrom").''; $emailarray = CMailFile::getArrayAddress($object->email_from); - foreach($emailarray as $email => $name) { + foreach ($emailarray as $email => $name) { if ($name && $name != $email) { print dol_escape_htmltag($name).' <'.$email; print '>'; @@ -266,7 +266,7 @@ if ($object->fetch($id) >= 0) // Errors to print '
'.$langs->trans("MailErrorsTo").''; $emailarray = CMailFile::getArrayAddress($object->email_errorsto); - foreach($emailarray as $email => $name) { + foreach ($emailarray as $email => $name) { if ($name != $email) { print dol_escape_htmltag($name).' <'.$email; print '>'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 887c99e7aeb..481d4021e33 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -931,105 +931,105 @@ if ($resql) { print ' '; $form->form_availability('', $obj->availability, 'none', 1); print ''.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_ttc)."'.price($totalInvoiced)."'.price($totalInvoiced)."'; if ($userstatic->id) print $userstatic->getLoginUrl(1); print "'; if ($obj->socid > 0) { - $listsalesrepresentatives=$companystatic->getSalesRepresentatives($user); + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) dol_print_error($db); - $nbofsalesrepresentative=count($listsalesrepresentatives); + $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { print ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e8dde584661..43a0cde43c1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -993,148 +993,148 @@ if ($resql) } } print ''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; print dol_print_date($db->jdate($obj->date_commande), 'day'); print ''; print dol_print_date($db->jdate($obj->date_delivery), 'day'); print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''.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 ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'; print ''; // Company print ''; // User print ''; // Year print ''; @@ -261,11 +261,11 @@ print ''; print ''; print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while ($year && $oldyear > $year+1) + while ($year && $oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -281,7 +281,7 @@ foreach ($data as $val) print ''; print ''; print ''; - $oldyear=$year; + $oldyear = $year; } print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; -$filter=''; +$filter = ''; print $form->select_company($socid, 'socid', $filter, 1, 1, 0, array(), 0, '', 'style="width: 95%"'); print '
'.$langs->trans("User").''; -$include=''; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $include='hierarchy'; +$include = ''; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $include = 'hierarchy'; print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
'.$langs->trans("Year").''; -if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
'.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).'
'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b4fa97e209e..00aa9deb4df 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1139,205 +1139,205 @@ if ($resql) print $thirdpartystatic->getNomUrl(1, 'customer'); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; print $obj->town; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; print $obj->zip; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "".$obj->state_name."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Staff - if (! empty($arrayfields['staff.code']['checked'])) + if (!empty($arrayfields['staff.code']['checked'])) { print ''; - if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1); + if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1); print $staffArray[$obj->staff_code]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment terms - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Module Source - if (! empty($arrayfields['f.module_source']['checked'])) + if (!empty($arrayfields['f.module_source']['checked'])) { print ''; print $obj->module_source; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // POS Terminal - if (! empty($arrayfields['f.pos_source']['checked'])) + if (!empty($arrayfields['f.pos_source']['checked'])) { print ''; print $obj->pos_source; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Amount HT - if (! empty($arrayfields['f.total_ht']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { print ''.price($obj->total_ht)."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ht'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; $totalarray['val']['f.total_ht'] += $obj->total_ht; } // Amount VAT - if (! empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_vat']['checked'])) { print ''.price($obj->total_vat)."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_vat'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; $totalarray['val']['f.total_vat'] += $obj->total_vat; } // Amount LocalTax1 - if (! empty($arrayfields['f.total_localtax1']['checked'])) + if (!empty($arrayfields['f.total_localtax1']['checked'])) { print ''.price($obj->total_localtax1)."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax1'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; } // Amount LocalTax2 - if (! empty($arrayfields['f.total_localtax2']['checked'])) + if (!empty($arrayfields['f.total_localtax2']['checked'])) { print ''.price($obj->total_localtax2)."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax2'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; } // Amount TTC - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { print ''.price($obj->total_ttc)."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } - if(! empty($arrayfields['f.retained_warranty']['checked'])) + if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''.(! empty($obj->retained_warranty)?price($obj->retained_warranty).'%':' ').''; + print ''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''; } - if (! empty($arrayfields['dynamount_payed']['checked'])) + if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').''; // TODO Use a denormalized field - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalam'; + print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; $totalarray['val']['totalam'] += $totalpay; } - if (! empty($arrayfields['rtp']['checked'])) + if (!empty($arrayfields['rtp']['checked'])) { - print ''.(! empty($remaintopay)?price($remaintopay, 0, $langs):' ').''; // TODO Use a denormalized field - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='rtp'; + print ''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''; // TODO Use a denormalized field + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; $totalarray['val']['rtp'] += $remaintopay; } // 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); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date closing - if (! empty($arrayfields['f.date_closing']['checked'])) + if (!empty($arrayfields['f.date_closing']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); print ""; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; if (($massactionbutton || $massaction) && $contextpage != 'poslist') // 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->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print ''; } - print '' ; - if (! $i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; print "\n"; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index ababa20b50a..efd16970227 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -33,16 +33,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'sclist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist'; // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; -if ($user->socid) $socid=$user->socid; +$socid = isset($_GET["socid"]) ? $_GET["socid"] : ''; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', '', 'charges'); $search_ref = GETPOST('search_ref', 'int'); @@ -50,7 +50,7 @@ $search_label = GETPOST('search_label', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_status = GETPOST('search_status', 'int'); $search_day_lim = GETPOST('search_day_lim', 'int'); -$search_month_lim = GETPOST('search_month_lim', 'int'); +$search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -61,40 +61,40 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="cs.date_ech"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "cs.date_ech"; +if (!$sortorder) $sortorder = "DESC"; -$year=GETPOST("year", 'int'); -$filtre=GETPOST("filtre", 'int'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'int'); -if (! GETPOSTISSET('search_typeid')) +if (!GETPOSTISSET('search_typeid')) { - $newfiltre=str_replace('filtre=', '', $filtre); - $filterarray=explode('-', $newfiltre); - foreach($filterarray as $val) + $newfiltre = str_replace('filtre=', '', $filtre); + $filterarray = explode('-', $newfiltre); + foreach ($filterarray as $val) { - $part=explode(':', $val); - if ($part[0] == 'cs.fk_type') $search_typeid=$part[1]; + $part = explode(':', $val); + if ($part[0] == 'cs.fk_type') $search_typeid = $part[1]; } } else { - $search_typeid=GETPOST('search_typeid', 'int'); + $search_typeid = GETPOST('search_typeid', 'int'); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref=""; - $search_label=""; - $search_amount=""; - $search_status=''; - $search_typeid=""; - $year=""; - $search_day_lim=''; - $search_year_lim=''; - $search_month_lim=''; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $search_label = ""; + $search_amount = ""; + $search_status = ''; + $search_typeid = ""; + $year = ""; + $search_day_lim = ''; + $search_year_lim = ''; + $search_month_lim = ''; + $toselect = ''; + $search_array_options = array(); } @@ -105,25 +105,25 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $formother = new FormOther($db); $formsocialcontrib = new FormSocialContrib($db); -$chargesociale_static=new ChargeSociales($db); +$chargesociale_static = new ChargeSociales($db); llxHeader('', $langs->trans("SocialContributions")); $sql = "SELECT cs.rowid as id, cs.fk_type as type, "; -$sql.= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; -$sql.= " c.libelle as type_label,"; -$sql.= " SUM(pc.amount) as alreadypayed"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; -$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; -$sql.= " WHERE cs.fk_type = c.id"; -$sql.= " AND cs.entity = ".$conf->entity; +$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; +$sql .= " c.libelle as type_label,"; +$sql .= " SUM(pc.amount) as alreadypayed"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; +$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; +$sql .= " WHERE cs.fk_type = c.id"; +$sql .= " AND cs.entity = ".$conf->entity; // Search criteria -if ($search_ref) $sql.=" AND cs.rowid=".$db->escape($search_ref); -if ($search_label) $sql.=natural_search("cs.libelle", $search_label); -if ($search_amount) $sql.=natural_search("cs.amount", price2num(trim($search_amount)), 1); -if ($search_status != '' && $search_status >= 0) $sql.=" AND cs.paye = ".$db->escape($search_status); -$sql.= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); +if ($search_ref) $sql .= " AND cs.rowid=".$db->escape($search_ref); +if ($search_label) $sql .= natural_search("cs.libelle", $search_label); +if ($search_amount) $sql .= natural_search("cs.amount", price2num(trim($search_amount)), 1); +if ($search_status != '' && $search_status >= 0) $sql .= " AND cs.paye = ".$db->escape($search_status); +$sql .= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); //$sql.= dolSqlDateFilter("cs.periode", 0, 0, $year); if ($year > 0) { @@ -185,7 +185,7 @@ if ($resql) if ($year) { - $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":""); + $center = ($year ? "".img_previous()." ".$langs->trans("Year")." $year ".img_next()."" : ""); print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'invoicing', 0, $newcardbutton, '', $limit); } else @@ -219,9 +219,9 @@ if ($resql) print ''; // Period end date print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year_lim?$search_year_lim:-1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; // Amount print ''; @@ -230,12 +230,12 @@ if ($resql) print ' '; // Status print ''; - $liststatus=array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); + $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; print "\n"; @@ -251,30 +251,30 @@ if ($resql) print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $chargesociale_static->id=$obj->id; - $chargesociale_static->ref=$obj->id; - $chargesociale_static->label=$obj->label; - $chargesociale_static->type_label=$obj->type_label; + $chargesociale_static->id = $obj->id; + $chargesociale_static->ref = $obj->id; + $chargesociale_static->label = $obj->label; + $chargesociale_static->type_label = $obj->type_label; print ''; // Ref print "".$chargesociale_static->getNomUrl(1, '20')."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Label print "".dol_trunc($obj->label, 42)."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print "".$obj->type_label."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Date end period print ''; @@ -287,24 +287,24 @@ if ($resql) print ' '; } print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Amount print ''.price($obj->amount).''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; // Due date print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; $i++; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 7e74e013580..8d49711b121 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -36,21 +36,21 @@ $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) $socid = $user->socid; -if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); -if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); +if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); +if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = $conf->global->ACCOUNTING_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); +if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta"); -$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; -$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -if (! $sortorder) $sortorder="asc"; -if (! $sortfield) $sortfield="name"; +$sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"]; +$sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"]; +if (!$sortorder) $sortorder = "asc"; +if (!$sortfield) $sortfield = "name"; // Date range -$year=GETPOST("year"); -$month=GETPOST("month"); +$year = GETPOST("year"); +$month = GETPOST("month"); $date_startyear = GETPOST("date_startyear"); $date_startmonth = GETPOST("date_startmonth"); $date_startday = GETPOST("date_startday"); @@ -67,49 +67,49 @@ if (empty($year)) $month_current = strftime("%m", dol_now()); $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); -$date_end=dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); +$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); +$date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q = GETPOST("q") ?GETPOST("q") : 0; + if ($q == 0) { // We define date_start and date_end - $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_end=$year_start; - $month_end=$month_start; - if (! GETPOST("month")) // If month not forced + $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_end = $year_start; + $month_end = $month_start; + if (!GETPOST("month")) // If month not forced { - if (! GETPOST('year') && $month_start > $month_current) + if (!GETPOST('year') && $month_start > $month_current) { $year_start--; $year_end--; } - $month_end=$month_start-1; - if ($month_end < 1) $month_end=12; + $month_end = $month_start - 1; + if ($month_end < 1) $month_end = 12; else $year_end++; } - $date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } else { // TODO We define q } // $date_start and $date_end are defined. We force $year_start and $nbofyear -$tmps=dol_getdate($date_start); +$tmps = dol_getdate($date_start); $year_start = $tmps['year']; -$tmpe=dol_getdate($date_end); +$tmpe = dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $year_start) + 1; -$commonparams=array(); -$commonparams['modecompta']=$modecompta; +$commonparams = array(); +$commonparams['modecompta'] = $modecompta; $commonparams['sortorder'] = $sortorder; $commonparams['sortfield'] = $sortfield; @@ -124,15 +124,15 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; -$tableparams['subcat'] = ($subcat === true)?'yes':''; +$tableparams['subcat'] = ($subcat === true) ? 'yes' : ''; // Adding common parameters $allparams = array_merge($commonparams, $headerparams, $tableparams); $headerparams = array_merge($commonparams, $headerparams); $tableparams = array_merge($commonparams, $tableparams); -foreach($allparams as $key => $value) { - $paramslink .= '&' . $key . '=' . $value; +foreach ($allparams as $key => $value) { + $paramslink .= '&'.$key.'='.$value; } /* @@ -141,77 +141,77 @@ foreach($allparams as $key => $value) { llxHeader(); -$form=new Form($db); +$form = new Form($db); // TODO Report from bookkeeping not yet available, so we switch on report on business events -if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES"; -if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES"; +if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES"; +if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES"; // Show report header -if ($modecompta=="CREANCES-DETTES") { - $name=$langs->trans("Turnover").', '.$langs->trans("ByUserAuthorOfInvoice"); - $calcmode=$langs->trans("CalcModeDebt"); +if ($modecompta == "CREANCES-DETTES") { + $name = $langs->trans("Turnover").', '.$langs->trans("ByUserAuthorOfInvoice"); + $calcmode = $langs->trans("CalcModeDebt"); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $description=$langs->trans("RulesCADue"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); - else $description.= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $description = $langs->trans("RulesCADue"); + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); + $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } -elseif ($modecompta=="RECETTES-DEPENSES") +elseif ($modecompta == "RECETTES-DEPENSES") { - $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByUserAuthorOfInvoice"); - $calcmode=$langs->trans("CalcModeEngagement"); + $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByUserAuthorOfInvoice"); + $calcmode = $langs->trans("CalcModeEngagement"); //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $description=$langs->trans("RulesCAIn"); - $description.= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $description = $langs->trans("RulesCAIn"); + $description .= $langs->trans("DepositsAreIncluded"); + $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } -elseif ($modecompta=="BOOKKEEPING") +elseif ($modecompta == "BOOKKEEPING") { } -elseif ($modecompta=="BOOKKEEPINGCOLLECTED") +elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = ''.img_previous().' '.img_next().''; else $periodlink = ''; -$moreparam=array(); -if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; +$moreparam = array(); +if (!empty($modecompta)) $moreparam['modecompta'] = $modecompta; report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam, $calcmode); -if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } -$name=array(); +$name = array(); // Show array print '
'; // Extra parameters management -foreach($headerparams as $key => $value) +foreach ($headerparams as $key => $value) { print ''; } -$catotal=0; +$catotal = 0; if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid"; - $sql.= " WHERE f.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid"; + $sql .= " WHERE f.fk_statut in (1,2)"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { - $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } } else { /* @@ -219,31 +219,31 @@ if ($modecompta == 'CREANCES-DETTES') { * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ $sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(pf.amount) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.rowid = pf.fk_paiement"; - $sql.= " WHERE 1=1"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.rowid = pf.fk_paiement"; + $sql .= " WHERE 1=1"; if ($date_start && $date_end) { - $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } } -$sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; +if ($socid) $sql .= " AND f.fk_soc = ".$socid; $sql .= " GROUP BY u.rowid, u.lastname, u.firstname"; $sql .= " ORDER BY u.rowid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); $amount_ht[$obj->rowid] = $obj->amount; $amount[$obj->rowid] = $obj->amount_ttc; $name[$obj->rowid] = $obj->name.' '.$obj->firstname; - $catotal_ht+=$obj->amount; - $catotal+=$obj->amount_ttc; + $catotal_ht += $obj->amount; + $catotal += $obj->amount_ttc; $i++; } } else { @@ -253,29 +253,29 @@ if ($result) { // Adding old-version payments, non-bound by "paiement_facture" then without User if ($modecompta != 'CREANCES-DETTES') { $sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql.= " WHERE pf.rowid IS NULL"; - $sql.= " AND p.fk_bank = b.rowid"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= ", ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " WHERE pf.rowid IS NULL"; + $sql .= " AND p.fk_bank = b.rowid"; + $sql .= " AND b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; if ($date_start && $date_end) { - $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } - $sql.= " GROUP BY rowidx, name, firstname"; - $sql.= " ORDER BY rowidx"; + $sql .= " GROUP BY rowidx, name, firstname"; + $sql .= " ORDER BY rowidx"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); $amount[$obj->rowidx] = $obj->amount_ttc; $name[$obj->rowidx] = $obj->name.' '.$obj->firstname; - $catotal+=$obj->amount_ttc; + $catotal += $obj->amount_ttc; $i++; } } else { @@ -283,10 +283,10 @@ if ($modecompta != 'CREANCES-DETTES') { } } -$morefilter=''; +$morefilter = ''; print '
'; -print ''."\n"; +print '
'."\n"; print ""; print_liste_field_titre( @@ -343,45 +343,45 @@ print_liste_field_titre( print "\n"; if (count($amount)) { - $arrayforsort=$name; + $arrayforsort = $name; // We define arrayforsort if ($sortfield == 'name' && $sortorder == 'asc') { asort($name); - $arrayforsort=$name; + $arrayforsort = $name; } if ($sortfield == 'name' && $sortorder == 'desc') { arsort($name); - $arrayforsort=$name; + $arrayforsort = $name; } if ($sortfield == 'amount_ht' && $sortorder == 'asc') { asort($amount_ht); - $arrayforsort=$amount_ht; + $arrayforsort = $amount_ht; } if ($sortfield == 'amount_ht' && $sortorder == 'desc') { arsort($amount_ht); - $arrayforsort=$amount_ht; + $arrayforsort = $amount_ht; } if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { asort($amount); - $arrayforsort=$amount; + $arrayforsort = $amount; } if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { arsort($amount); - $arrayforsort=$amount; + $arrayforsort = $amount; } $i = 0; - foreach($arrayforsort as $key => $value) { + foreach ($arrayforsort as $key => $value) { print ''; // Third party - $fullname=$name[$key]; + $fullname = $name[$key]; if ($key >= 0) { - $linkname=''.img_object($langs->trans("ShowUser"), 'user').' '.$fullname.''; + $linkname = ''.img_object($langs->trans("ShowUser"), 'user').' '.$fullname.''; } else { - $linkname=$langs->trans("PaymentsNotLinkedToUser"); + $linkname = $langs->trans("PaymentsNotLinkedToUser"); } print "\n"; @@ -427,13 +427,13 @@ if (count($amount)) { // Other stats print ''; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index b6dc847f6a8..5e7340f20c8 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -40,12 +40,12 @@ $langs->loadLangs(array('companies', 'categories', 'bills', 'compta')); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = $conf->global->ACCOUNTING_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); +if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta"); -$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; -$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -if (! $sortorder) $sortorder="asc"; -if (! $sortfield) $sortfield="nom"; +$sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"]; +$sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"]; +if (!$sortorder) $sortorder = "asc"; +if (!$sortfield) $sortfield = "nom"; $socid = GETPOST('socid', 'int'); @@ -58,12 +58,12 @@ if (GETPOST('subcat', 'alpha') === 'yes') { // Security check if ($user->socid > 0) $socid = $user->socid; -if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user, 'compta', '', '', 'resultat'); -if (! empty($conf->accounting->enabled)) $result=restrictedArea($user, 'accounting', '', '', 'comptarapport'); +if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat'); +if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); // Date range -$year=GETPOST("year", 'int'); -$month=GETPOST("month", 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); $search_societe = GETPOST("search_societe", 'alpha'); $search_zip = GETPOST("search_zip", 'alpha'); $search_town = GETPOST("search_town", 'alpha'); @@ -84,35 +84,35 @@ if (empty($year)) $month_current = strftime("%m", dol_now()); $year_start = $year; } -$date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q", "int")?GETPOST("q", "int"):0; + $q = GETPOST("q", "int") ?GETPOST("q", "int") : 0; if (empty($q)) { // We define date_start and date_end - $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_end=$year_start; - $month_end=$month_start; - if (! GETPOST("month")) // If month not forced + $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_end = $year_start; + $month_end = $month_start; + if (!GETPOST("month")) // If month not forced { - if (! GETPOST('year') && $month_start > $month_current) + if (!GETPOST('year') && $month_start > $month_current) { $year_start--; $year_end--; } - $month_end=$month_start-1; - if ($month_end < 1) $month_end=12; + $month_end = $month_start - 1; + if ($month_end < 1) $month_end = 12; else $year_end++; } - $date_start=dol_get_first_day($year_start, $month_start, false); $date_end=dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); } - if ($q==1) { $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); } - if ($q==2) { $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); } - if ($q==3) { $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); } - if ($q==4) { $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); } + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } } else { @@ -120,14 +120,14 @@ else } // $date_start and $date_end are defined. We force $year_start and $nbofyear -$tmps=dol_getdate($date_start); +$tmps = dol_getdate($date_start); $year_start = $tmps['year']; -$tmpe=dol_getdate($date_end); +$tmpe = dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $year_start) + 1; -$commonparams=array(); -$commonparams['modecompta']=$modecompta; +$commonparams = array(); +$commonparams['modecompta'] = $modecompta; $commonparams['sortorder'] = $sortorder; $commonparams['sortfield'] = $sortfield; @@ -146,15 +146,15 @@ $tableparams['search_societe'] = $search_societe; $tableparams['search_zip'] = $search_zip; $tableparams['search_town'] = $search_town; $tableparams['search_country'] = $search_country; -$tableparams['subcat'] = ($subcat === true)?'yes':''; +$tableparams['subcat'] = ($subcat === true) ? 'yes' : ''; // Adding common parameters $allparams = array_merge($commonparams, $headerparams, $tableparams); $headerparams = array_merge($commonparams, $headerparams); $tableparams = array_merge($commonparams, $tableparams); -foreach($allparams as $key => $value) { - $paramslink .= '&' . $key . '=' . $value; +foreach ($allparams as $key => $value) { + $paramslink .= '&'.$key.'='.$value; } @@ -164,89 +164,89 @@ foreach($allparams as $key => $value) { llxHeader(); -$form=new Form($db); -$thirdparty_static=new Societe($db); +$form = new Form($db); +$thirdparty_static = new Societe($db); $formother = new FormOther($db); // TODO Report from bookkeeping not yet available, so we switch on report on business events -if ($modecompta=="BOOKKEEPING") $modecompta="CREANCES-DETTES"; -if ($modecompta=="BOOKKEEPINGCOLLECTED") $modecompta="RECETTES-DEPENSES"; +if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES"; +if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES"; // Show report header -if ($modecompta=="CREANCES-DETTES") +if ($modecompta == "CREANCES-DETTES") { - $name=$langs->trans("Turnover").', '.$langs->trans("ByThirdParties"); - $calcmode=$langs->trans("CalcModeDebt"); + $name = $langs->trans("Turnover").', '.$langs->trans("ByThirdParties"); + $calcmode = $langs->trans("CalcModeDebt"); //$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $description=$langs->trans("RulesCADue"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); - else $description.= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $description = $langs->trans("RulesCADue"); + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); + else $description .= $langs->trans("DepositsAreIncluded"); + $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } -elseif ($modecompta=="RECETTES-DEPENSES") +elseif ($modecompta == "RECETTES-DEPENSES") { - $name=$langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties"); - $calcmode=$langs->trans("CalcModeEngagement"); + $name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByThirdParties"); + $calcmode = $langs->trans("CalcModeEngagement"); //$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $description=$langs->trans("RulesCAIn"); - $description.= $langs->trans("DepositsAreIncluded"); - $builddate=dol_now(); + $description = $langs->trans("RulesCAIn"); + $description .= $langs->trans("DepositsAreIncluded"); + $builddate = dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } -elseif ($modecompta=="BOOKKEEPING") +elseif ($modecompta == "BOOKKEEPING") { } -elseif ($modecompta=="BOOKKEEPINGCOLLECTED") +elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } -$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().''.img_next().''; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = ''.img_previous().''.img_next().''; else $periodlink = ''; report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); -if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } -$name=array(); +$name = array(); // Show Array -$catotal=0; +$catotal = 0; if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,"; - $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) // Without any category { - $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; + $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; } elseif ($selected_cat) // Into a specific category { - $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; + $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } - $sql.= " WHERE f.fk_statut in (1,2)"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; + $sql .= " WHERE f.fk_statut in (1,2)"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql .= " AND f.type IN (0,1,2,3,5)"; } - $sql.= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.fk_soc = s.rowid"; if ($date_start && $date_end) { - $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } if ($selected_cat === -2) // Without any category { - $sql.=" AND cs.fk_soc is null"; + $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql.= " AND (c.rowid = ".$db->escape($selected_cat); - if ($subcat) $sql.=" OR c.fk_parent = " . $db->escape($selected_cat); - $sql.= ")"; - $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; + $sql .= " AND (c.rowid = ".$db->escape($selected_cat); + if ($subcat) $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); + $sql .= ")"; + $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } } else { /* @@ -254,50 +254,50 @@ if ($modecompta == 'CREANCES-DETTES') { * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= ", ".MAIN_DB_PREFIX."paiement as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) // Without any category { - $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; + $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; } elseif ($selected_cat) // Into a specific category { - $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; + $sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } - $sql.= " WHERE p.rowid = pf.fk_paiement"; - $sql.= " AND pf.fk_facture = f.rowid"; - $sql.= " AND f.fk_soc = s.rowid"; + $sql .= " WHERE p.rowid = pf.fk_paiement"; + $sql .= " AND pf.fk_facture = f.rowid"; + $sql .= " AND f.fk_soc = s.rowid"; if ($date_start && $date_end) { - $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } if ($selected_cat === -2) // Without any category { - $sql.=" AND cs.fk_soc is null"; + $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql.= " AND (c.rowid = ".$selected_cat; - if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; - $sql.= ")"; - $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; + $sql .= " AND (c.rowid = ".$selected_cat; + if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= ")"; + $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } } -if (!empty($search_societe)) $sql.= natural_search('s.nom', $search_societe); -if (!empty($search_zip)) $sql.= natural_search('s.zip', $search_zip); -if (!empty($search_town)) $sql.= natural_search('s.town', $search_town); -if ($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.''; -$sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; -$sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; -$sql.= " ORDER BY s.rowid"; +if (!empty($search_societe)) $sql .= natural_search('s.nom', $search_societe); +if (!empty($search_zip)) $sql .= natural_search('s.zip', $search_zip); +if (!empty($search_town)) $sql .= natural_search('s.town', $search_town); +if ($search_country > 0) $sql .= ' AND s.fk_pays = '.$search_country.''; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; +if ($socid) $sql .= " AND f.fk_soc = ".$socid; +$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; +$sql .= " ORDER BY s.rowid"; //echo $sql; dol_syslog("casoc", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); $amount_ht[$obj->socid] = $obj->amount; @@ -306,8 +306,8 @@ if ($result) { $address_zip[$obj->socid] = $obj->zip; $address_town[$obj->socid] = $obj->town; $address_pays[$obj->socid] = getCountry($obj->fk_pays); - $catotal_ht+=$obj->amount; - $catotal+=$obj->amount_ttc; + $catotal_ht += $obj->amount; + $catotal += $obj->amount_ttc; $i++; } } else { @@ -317,22 +317,22 @@ if ($result) { // On ajoute les paiements anciennes version, non lies par paiement_facture if ($modecompta != 'CREANCES-DETTES') { $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; - $sql.= " WHERE pf.rowid IS NULL"; - $sql.= " AND p.fk_bank = b.rowid"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " GROUP BY socid, name"; - $sql.= " ORDER BY name"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= ", ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; + $sql .= " WHERE pf.rowid IS NULL"; + $sql .= " AND p.fk_bank = b.rowid"; + $sql .= " AND b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " GROUP BY socid, name"; + $sql .= " ORDER BY name"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); $amount[$obj->rowid] += $obj->amount_ttc; @@ -340,7 +340,7 @@ if ($modecompta != 'CREANCES-DETTES') { $address_zip[$obj->rowid] = $obj->zip; $address_town[$obj->rowid] = $obj->town; $address_pays[$obj->rowid] = getCountry($obj->fk_pays); - $catotal+=$obj->amount_ttc; + $catotal += $obj->amount_ttc; $i++; } } else { @@ -353,22 +353,22 @@ if ($modecompta != 'CREANCES-DETTES') { $i = 0; print ''; // Extra parameters management -foreach($headerparams as $key => $value) +foreach ($headerparams as $key => $value) { print ''; } -$moreforfilter=''; +$moreforfilter = ''; print '
'; -print '
".$linkname."'; - if (! empty($conf->propal->enabled) && $key>0) { + if (!empty($conf->propal->enabled) && $key > 0) { print ' '.img_picto($langs->trans("ProposalStats"), "stats").' '; } - if (! empty($conf->commande->enabled) && $key>0) { + if (!empty($conf->commande->enabled) && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (! empty($conf->facture->enabled) && $key>0) { + if (!empty($conf->facture->enabled) && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print '
'."\n"; +print '
'."\n"; // Category filter print ''; print ''; // Third party - $fullname=$name[$key]; + $fullname = $name[$key]; if ($key > 0) { - $thirdparty_static->id=$key; - $thirdparty_static->name=$fullname; - $thirdparty_static->client=1; - $linkname=$thirdparty_static->getNomUrl(1, 'customer'); + $thirdparty_static->id = $key; + $thirdparty_static->name = $fullname; + $thirdparty_static->client = 1; + $linkname = $thirdparty_static->getNomUrl(1, 'customer'); } else { - $linkname=$langs->trans("PaymentsNotLinkedToInvoice"); + $linkname = $langs->trans("PaymentsNotLinkedToInvoice"); } print "\n"; @@ -603,13 +603,13 @@ if (count($amount)) { // Other stats print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ae6bc068628..c666456661e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -43,98 +43,98 @@ $langs->loadLangs(array("companies", "suppliers", "categories")); $socialnetworks = getArrayOfSocialNetworks(); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'contactlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist'; // Security check $id = GETPOST('id', 'int'); $contactid = GETPOST('id', 'int'); -$ref = ''; // There is no ref for contacts -if ($user->socid) $socid=$user->socid; +$ref = ''; // There is no ref for contacts +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'contact', $contactid, ''); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars -$search_phone=GETPOST("search_phone", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars +$search_phone = GETPOST("search_phone", 'alpha'); -$search_id=trim(GETPOST("search_id", "int")); -$search_firstlast_only=GETPOST("search_firstlast_only", 'alpha'); -$search_lastname=GETPOST("search_lastname", 'alpha'); -$search_firstname=GETPOST("search_firstname", 'alpha'); -$search_societe=GETPOST("search_societe", 'alpha'); -$search_poste=GETPOST("search_poste", 'alpha'); -$search_phone_perso=GETPOST("search_phone_perso", 'alpha'); -$search_phone_pro=GETPOST("search_phone_pro", 'alpha'); -$search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); -$search_fax=GETPOST("search_fax", 'alpha'); -$search_email=GETPOST("search_email", 'alpha'); -$search_no_email=GETPOST("search_no_email", 'int'); -if (! empty($conf->socialnetworks->enabled)) { +$search_id = trim(GETPOST("search_id", "int")); +$search_firstlast_only = GETPOST("search_firstlast_only", 'alpha'); +$search_lastname = GETPOST("search_lastname", 'alpha'); +$search_firstname = GETPOST("search_firstname", 'alpha'); +$search_societe = GETPOST("search_societe", 'alpha'); +$search_poste = GETPOST("search_poste", 'alpha'); +$search_phone_perso = GETPOST("search_phone_perso", 'alpha'); +$search_phone_pro = GETPOST("search_phone_pro", 'alpha'); +$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); +$search_fax = GETPOST("search_fax", 'alpha'); +$search_email = GETPOST("search_email", 'alpha'); +$search_no_email = GETPOST("search_no_email", 'int'); +if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { $search_{$key} = GETPOST("search_".$key, 'alpha'); } } } -$search_priv=GETPOST("search_priv", 'alpha'); -$search_categ=GETPOST("search_categ", 'int'); -$search_categ_thirdparty=GETPOST("search_categ_thirdparty", 'int'); -$search_categ_supplier=GETPOST("search_categ_supplier", 'int'); -$search_status=GETPOST("search_status", 'int'); -$search_type=GETPOST('search_type', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_import_key=GETPOST("search_import_key", "alpha"); -$search_country=GETPOST("search_country", 'intcomma'); -$search_roles=GETPOST("search_roles", 'array'); +$search_priv = GETPOST("search_priv", 'alpha'); +$search_categ = GETPOST("search_categ", 'int'); +$search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'int'); +$search_categ_supplier = GETPOST("search_categ_supplier", 'int'); +$search_status = GETPOST("search_status", 'int'); +$search_type = GETPOST('search_type', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_import_key = GETPOST("search_import_key", "alpha"); +$search_country = GETPOST("search_country", 'intcomma'); +$search_roles = GETPOST("search_roles", 'array'); -if ($search_status=='') $search_status=1; // always display active customer first +if ($search_status == '') $search_status = 1; // always display active customer first $optioncss = GETPOST('optioncss', 'alpha'); -$type=GETPOST("type", 'aZ'); -$view=GETPOST("view", 'alpha'); +$type = GETPOST("type", 'aZ'); +$view = GETPOST("view", 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -$userid=GETPOST('userid', 'int'); -$begin=GETPOST('begin'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="p.lastname"; +$userid = GETPOST('userid', 'int'); +$begin = GETPOST('begin'); +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "p.lastname"; if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; -$titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); +$titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); if ($type == "p") { - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactprospectlist'; - $titre.=' ('.$langs->trans("ThirdPartyProspects").')'; - $urlfiche="card.php"; + if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactprospectlist'; + $titre .= ' ('.$langs->trans("ThirdPartyProspects").')'; + $urlfiche = "card.php"; } if ($type == "c") { - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactcustomerlist'; - $titre.=' ('.$langs->trans("ThirdPartyCustomers").')'; - $urlfiche="card.php"; + if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactcustomerlist'; + $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; + $urlfiche = "card.php"; } elseif ($type == "f") { - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactsupplierlist'; - $titre.=' ('.$langs->trans("ThirdPartySuppliers").')'; - $urlfiche="card.php"; + if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactsupplierlist'; + $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; + $urlfiche = "card.php"; } elseif ($type == "o") { - if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactotherlist'; - $titre.=' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; - $urlfiche=""; + if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactotherlist'; + $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; + $urlfiche = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -172,7 +172,7 @@ $arrayfields = array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'checked'=>1), - 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), + 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -180,7 +180,7 @@ $arrayfields = array( 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); -if (! empty($conf->socialnetworks->enabled)) { +if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { $arrayfields['p.'.$key] = array( @@ -229,91 +229,91 @@ if (empty($reshook)) // Did we click on 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 { - $sall=""; - $search_id=''; - $search_firstlast_only=""; - $search_lastname=""; - $search_firstname=""; - $search_societe=""; - $search_town=""; - $search_zip=""; - $search_country=""; - $search_poste=""; - $search_phone=""; - $search_phone_perso=""; - $search_phone_pro=""; - $search_phone_mobile=""; - $search_fax=""; - $search_email=""; - $search_no_email=-1; - if (! empty($conf->socialnetworks->enabled)) { + $sall = ""; + $search_id = ''; + $search_firstlast_only = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_societe = ""; + $search_town = ""; + $search_zip = ""; + $search_country = ""; + $search_poste = ""; + $search_phone = ""; + $search_phone_perso = ""; + $search_phone_pro = ""; + $search_phone_mobile = ""; + $search_fax = ""; + $search_email = ""; + $search_no_email = -1; + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { $search_{$key} = ""; } } } - $search_priv=""; - $search_status=-1; - $search_categ=''; - $search_categ_thirdparty=''; - $search_categ_supplier=''; - $search_import_key=''; - $toselect=''; - $search_array_options=array(); - $search_roles=array(); + $search_priv = ""; + $search_status = -1; + $search_categ = ''; + $search_categ_thirdparty = ''; + $search_categ_supplier = ''; + $search_import_key = ''; + $toselect = ''; + $search_array_options = array(); + $search_roles = array(); } // Mass actions - $objectclass='Contact'; - $objectlabel='Contact'; + $objectclass = 'Contact'; + $objectlabel = 'Contact'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($search_priv < 0) $search_priv=''; +if ($search_priv < 0) $search_priv = ''; /* * View */ -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); -$contactstatic=new Contact($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); +$contactstatic = new Contact($db); -$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; -$sql.= " p.socialnetworks,"; -$sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; -$sql.= " co.label as country, co.code as country_code"; +$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; +$sql .= " p.socialnetworks,"; +$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; +$sql .= " co.label as country, co.code as country_code"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ -if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ -if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ +if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ +if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= ' WHERE p.entity IN ('.getEntity('socpeople').')'; +$sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; + $sql .= " AND (sc.fk_user = ".$user->id." OR p.fk_soc IS NULL)"; } -if (! empty($userid)) // propre au commercial +if (!empty($userid)) // propre au commercial { $sql .= " AND p.fk_user_creat=".$db->escape($userid); } @@ -329,46 +329,46 @@ else if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")"; } -if ($search_categ > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cc.fk_categorie IS NULL"; -if ($search_categ_thirdparty > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty); -if ($search_categ_thirdparty == -2) $sql.= " AND cs.fk_categorie IS NULL"; -if ($search_categ_supplier > 0) $sql.= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); -if ($search_categ_supplier == -2) $sql.= " AND cs2.fk_categorie IS NULL"; +if ($search_categ > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_categ_thirdparty > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty); +if ($search_categ_thirdparty == -2) $sql .= " AND cs.fk_categorie IS NULL"; +if ($search_categ_supplier > 0) $sql .= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier); +if ($search_categ_supplier == -2) $sql .= " AND cs2.fk_categorie IS NULL"; -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); -if (strlen($search_phone)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); -if (strlen($search_cti)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti); -if (strlen($search_firstlast_only)) $sql.= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only); +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if (strlen($search_phone)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone); +if (strlen($search_cti)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti); +if (strlen($search_firstlast_only)) $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only); -if ($search_id > 0) $sql.= natural_search("p.rowid", $search_id, 1); -if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname); -if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname); -if ($search_societe) $sql.= natural_search('s.nom', $search_societe); +if ($search_id > 0) $sql .= natural_search("p.rowid", $search_id, 1); +if ($search_lastname) $sql .= natural_search('p.lastname', $search_lastname); +if ($search_firstname) $sql .= natural_search('p.firstname', $search_firstname); +if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')'; -if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste); -if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso); -if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro); -if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile); -if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); -if (! empty($conf->socialnetworks->enabled)) { +if (strlen($search_poste)) $sql .= natural_search('p.poste', $search_poste); +if (strlen($search_phone_perso)) $sql .= natural_search('p.phone_perso', $search_phone_perso); +if (strlen($search_phone_pro)) $sql .= natural_search('p.phone', $search_phone_pro); +if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $search_phone_mobile); +if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax); +if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_{$key})) { //$sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); - $sql.= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; + $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; } } } -if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); -if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); -if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); -if (count($search_roles)>0) { +if (strlen($search_email)) $sql .= natural_search('p.email', $search_email); +if (strlen($search_zip)) $sql .= natural_search("p.zip", $search_zip); +if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); +if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } -if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email); -if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); -if ($search_import_key) $sql.= natural_search("p.import_key", $search_import_key); +if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email); +if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); +if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type { $sql .= " AND p.fk_soc IS NULL"; @@ -617,52 +617,52 @@ if (!empty($arrayfields['p.town']['checked'])) print ''; }*/ // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } -if (! empty($arrayfields['p.phone']['checked'])) +if (!empty($arrayfields['p.phone']['checked'])) { print ''; } -if (! empty($arrayfields['p.phone_perso']['checked'])) +if (!empty($arrayfields['p.phone_perso']['checked'])) { print ''; } -if (! empty($arrayfields['p.phone_mobile']['checked'])) +if (!empty($arrayfields['p.phone_mobile']['checked'])) { print ''; } -if (! empty($arrayfields['p.fax']['checked'])) +if (!empty($arrayfields['p.fax']['checked'])) { print ''; } -if (! empty($arrayfields['p.email']['checked'])) +if (!empty($arrayfields['p.email']['checked'])) { print ''; } -if (! empty($arrayfields['p.no_email']['checked'])) +if (!empty($arrayfields['p.no_email']['checked'])) { print ''; } -if (! empty($conf->socialnetworks->enabled)) { +if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - if (! empty($arrayfields['p.'.$key]['checked'])) + if (!empty($arrayfields['p.'.$key]['checked'])) { print ''; } -if (! empty($arrayfields['p.priv']['checked'])) +if (!empty($arrayfields['p.priv']['checked'])) { print ''; } @@ -726,32 +726,32 @@ print ''; // Ligne des titres print ''; -if (! empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'], $_SERVER["PHP_SELF"], "p.lastname", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'], $_SERVER["PHP_SELF"], "p.firstname", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'], $_SERVER["PHP_SELF"], "p.poste", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'], $_SERVER["PHP_SELF"], "p.zip", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'], $_SERVER["PHP_SELF"], "p.town", $begin, $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['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) { +if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); } -if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); -if (! empty($conf->socialnetworks->enabled)) { +if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if ($value['active'] && ! empty($arrayfields['p.'.$key]['checked'])) { + if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { print_liste_field_titre($arrayfields['p.'.$key]['label'], $_SERVER["PHP_SELF"], "p.".$key, $begin, $param, '', $sortfield, $sortorder); } } } -if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -780,67 +780,67 @@ print "\n"; $i = 0; -$totalarray=array(); +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); print ''; $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true); - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=''; - $contactstatic->id=$obj->rowid; - $contactstatic->statut=$obj->statut; - $contactstatic->poste=$obj->poste; - $contactstatic->email=$obj->email; - $contactstatic->phone_pro=$obj->phone_pro; - $contactstatic->phone_perso=$obj->phone_perso; - $contactstatic->phone_mobile=$obj->phone_mobile; - $contactstatic->zip=$obj->zip; - $contactstatic->town=$obj->town; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = ''; + $contactstatic->id = $obj->rowid; + $contactstatic->statut = $obj->statut; + $contactstatic->poste = $obj->poste; + $contactstatic->email = $obj->email; + $contactstatic->phone_pro = $obj->phone_pro; + $contactstatic->phone_perso = $obj->phone_perso; + $contactstatic->phone_mobile = $obj->phone_mobile; + $contactstatic->zip = $obj->zip; + $contactstatic->town = $obj->town; $contactstatic->socialnetworks = $arraysocialnetworks; $contactstatic->country = $obj->country; $contactstatic->country_code = $obj->country_code; // ID - if (! empty($arrayfields['p.rowid']['checked'])) + if (!empty($arrayfields['p.rowid']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Name - if (! empty($arrayfields['p.lastname']['checked'])) + if (!empty($arrayfields['p.lastname']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Firstname - if (! empty($arrayfields['p.firstname']['checked'])) + if (!empty($arrayfields['p.firstname']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Job position - if (! empty($arrayfields['p.poste']['checked'])) + if (!empty($arrayfields['p.poste']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['p.zip']['checked'])) + if (!empty($arrayfields['p.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['p.town']['checked'])) + if (!empty($arrayfields['p.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State /*if (! empty($arrayfields['state.nom']['checked'])) @@ -855,60 +855,60 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; }*/ // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone - if (! empty($arrayfields['p.phone']['checked'])) + if (!empty($arrayfields['p.phone']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone perso - if (! empty($arrayfields['p.phone_perso']['checked'])) + if (!empty($arrayfields['p.phone_perso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone mobile - if (! empty($arrayfields['p.phone_mobile']['checked'])) + if (!empty($arrayfields['p.phone_mobile']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Fax - if (! empty($arrayfields['p.fax']['checked'])) + if (!empty($arrayfields['p.fax']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // EMail - if (! empty($arrayfields['p.email']['checked'])) + if (!empty($arrayfields['p.email']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // No EMail - if (! empty($arrayfields['p.no_email']['checked'])) + if (!empty($arrayfields['p.no_email']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if ($value['active'] && ! empty($arrayfields['p.'.$key]['checked'])) { + if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } } } // Company - if (! empty($arrayfields['p.thirdparty']['checked'])) + if (!empty($arrayfields['p.thirdparty']['checked'])) { print '"; @@ -299,7 +299,7 @@ if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE print "\n"; } - $oldvallevel=$val['level']; + $oldvallevel = $val['level']; $nbofentries++; } @@ -318,7 +318,7 @@ if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE // Close db if mode is not noajax -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); @@ -348,7 +348,7 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, { $files = @scandir($fullpathselecteddir); - if (! empty($files)) + if (!empty($files)) { natcasesort($files); if (count($files) > 2) /* The 2 accounts for . and .. */ @@ -360,56 +360,56 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, { if ($file == 'temp') continue; - $nbofsubdir=0; - $nboffilesinsubdir=0; + $nbofsubdir = 0; + $nboffilesinsubdir = 0; - $val=array(); + $val = array(); // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan - foreach($sqltree as $key => $tmpval) + foreach ($sqltree as $key => $tmpval) { //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."
\n"; - if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database + if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) // We found equivalent record into database { - $val=$tmpval; - $resarray=tree_showpad($sqltree, $key, 1); + $val = $tmpval; + $resarray = tree_showpad($sqltree, $key, 1); // Refresh cache for this subdir if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t { - $result=$ecmdirstatic->fetch($val['id']); - $ecmdirstatic->ref=$ecmdirstatic->label; + $result = $ecmdirstatic->fetch($val['id']); + $ecmdirstatic->ref = $ecmdirstatic->label; - $result=$ecmdirstatic->refreshcachenboffile(0); - $val['cachenbofdoc']=$result; + $result = $ecmdirstatic->refreshcachenboffile(0); + $val['cachenbofdoc'] = $result; } - $a=$resarray[0]; - $nbofsubdir=$resarray[1]; - $nboffilesinsubdir=$resarray[2]; + $a = $resarray[0]; + $nbofsubdir = $resarray[1]; + $nboffilesinsubdir = $resarray[2]; break; } } //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; - if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/', $fullpathselecteddir)?'':'/') . $file))) + if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) { if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) { - $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; - $val['id']=0; - $val['label']=$file; - $val['description']=''; - $nboffilesinsubdir=$langs->trans("Unknown"); + $val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file; + $val['id'] = 0; + $val['label'] = $file; + $val['description'] = ''; + $nboffilesinsubdir = $langs->trans("Unknown"); } - $collapsedorexpanded='collapsed'; - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; - print '
  • '; // collapsed is opposite if expanded + $collapsedorexpanded = 'collapsed'; + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded'; + print '
  • '; // collapsed is opposite if expanded print ""; print dol_escape_htmltag($file); @@ -425,10 +425,10 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, // Nb of docs print '
  • '; print ''; // Edit link @@ -445,16 +445,16 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, if ($modulepart == 'ecm') { print '"; } @@ -467,17 +467,17 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, { //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; $newselecteddir = $val['fullrelativename']; - $newfullpathselecteddir=''; + $newfullpathselecteddir = ''; if ($modulepart == 'ecm') { - $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); + $newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); } elseif ($modulepart == 'medias') { - $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); + $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); } - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); + if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1); } print "\n"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0eadfba7ad0..614b17a4967 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1637,52 +1637,52 @@ class Form $includeUsers = implode(",", $user->getAllChildIds(1)); } - $out=''; + $out = ''; $outarray = array(); // Forge request to select users $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; - if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { - $sql.= ", e.label"; + $sql .= ", e.label"; } - $sql.= " FROM ".MAIN_DB_PREFIX ."user as u"; - if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."entity as e ON e.rowid=u.entity"; - if ($force_entity) $sql.= " WHERE u.entity IN (0,".$force_entity.")"; - else $sql.= " WHERE u.entity IS NOT NULL"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity"; + if ($force_entity) $sql .= " WHERE u.entity IN (0,".$force_entity.")"; + else $sql .= " WHERE u.entity IS NOT NULL"; } else { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " ON ug.fk_user = u.rowid"; - $sql.= " WHERE ug.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " ON ug.fk_user = u.rowid"; + $sql .= " WHERE ug.entity = ".$conf->entity; } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; } } - if (! empty($user->socid)) $sql.= " AND u.fk_soc = ".$user->socid; - if (is_array($exclude) && $excludeUsers) $sql.= " AND u.rowid NOT IN (".$excludeUsers.")"; - if ($includeUsers) $sql.= " AND u.rowid IN (".$includeUsers.")"; - if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql.= " AND u.statut <> 0"; - if (! empty($morefilter)) $sql.=" ".$morefilter; + if (!empty($user->socid)) $sql .= " AND u.fk_soc = ".$user->socid; + if (is_array($exclude) && $excludeUsers) $sql .= " AND u.rowid NOT IN (".$excludeUsers.")"; + if ($includeUsers) $sql .= " AND u.rowid IN (".$includeUsers.")"; + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0"; + if (!empty($morefilter)) $sql .= " ".$morefilter; if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname { - $sql.= " ORDER BY u.firstname ASC"; + $sql .= " ORDER BY u.firstname ASC"; } else { - $sql.= " ORDER BY u.lastname ASC"; + $sql .= " ORDER BY u.lastname ASC"; } dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -3797,11 +3797,11 @@ class Form $num = 0; $sql = "SELECT rowid, label, bank, clos as status, currency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity IN (".getEntity('bank_account').")"; - if ($status != 2) $sql.= " AND clos = ".(int) $status; - if ($filtre) $sql.=" AND ".$filtre; - $sql.= " ORDER BY label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql .= " WHERE entity IN (".getEntity('bank_account').")"; + if ($status != 2) $sql .= " AND clos = ".(int) $status; + if ($filtre) $sql .= " AND ".$filtre; + $sql .= " ORDER BY label"; dol_syslog(get_class($this)."::select_comptes", LOG_DEBUG); $result = $this->db->query($sql); @@ -3869,11 +3869,11 @@ class Form $num = 0; $sql = "SELECT rowid, name, fk_country, status, entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."establishment"; - $sql.= " WHERE 1=1"; - if ($status != 2) $sql.= " AND status = ".(int) $status; - if ($filtre) $sql.=" AND ".$filtre; - $sql.= " ORDER BY name"; + $sql .= " FROM ".MAIN_DB_PREFIX."establishment"; + $sql .= " WHERE 1=1"; + if ($status != 2) $sql .= " AND status = ".(int) $status; + if ($filtre) $sql .= " AND ".$filtre; + $sql .= " ORDER BY name"; dol_syslog(get_class($this)."::select_establishment", LOG_DEBUG); $result = $this->db->query($sql); @@ -5746,18 +5746,18 @@ class Form // If reset_scripts is not empty, print the link with the reset_scripts in the onClick if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) { - $retstring.=' '; + $retstring .= ' '; } } // Add a "Plus one hour" link if ($conf->use_javascript_ajax && $adddateof) { - $tmparray=dol_getdate($adddateof); + $tmparray = dol_getdate($adddateof); if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice"); - $retstring.=' -
    '; -print $langs->trans("Category") . ': ' . $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', true); +print $langs->trans("Category").': '.$formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', true); print ' '; -print $langs->trans("SubCats") . '? '; +print $langs->trans("SubCats").'? '; print '\n"; if (count($amount)) { - $arrayforsort=$name; + $arrayforsort = $name; // Defining array arrayforsort if ($sortfield == 'nom' && $sortorder == 'asc') { asort($name); - $arrayforsort=$name; + $arrayforsort = $name; } if ($sortfield == 'nom' && $sortorder == 'desc') { arsort($name); - $arrayforsort=$name; + $arrayforsort = $name; } if ($sortfield == 'amount_ht' && $sortorder == 'asc') { asort($amount_ht); - $arrayforsort=$amount_ht; + $arrayforsort = $amount_ht; } if ($sortfield == 'amount_ht' && $sortorder == 'desc') { arsort($amount_ht); - $arrayforsort=$amount_ht; + $arrayforsort = $amount_ht; } if ($sortfield == 'amount_ttc' && $sortorder == 'asc') { asort($amount); - $arrayforsort=$amount; + $arrayforsort = $amount; } if ($sortfield == 'amount_ttc' && $sortorder == 'desc') { arsort($amount); - $arrayforsort=$amount; + $arrayforsort = $amount; } if ($sortfield == 'zip' && $sortorder == 'asc') { asort($address_zip); - $arrayforsort=$address_zip; + $arrayforsort = $address_zip; } if ($sortfield == 'zip' && $sortorder == 'desc') { arsort($address_zip); - $arrayforsort=$address_zip; + $arrayforsort = $address_zip; } if ($sortfield == 'town' && $sortorder == 'asc') { asort($address_town); - $arrayforsort=$address_town; + $arrayforsort = $address_town; } if ($sortfield == 'town' && $sortorder == 'desc') { arsort($address_town); - $arrayforsort=$address_town; + $arrayforsort = $address_town; } if ($sortfield == 'country' && $sortorder == 'asc') { asort($address_pays); - $arrayforsort=$address_town; + $arrayforsort = $address_town; } if ($sortfield == 'country' && $sortorder == 'desc') { arsort($address_pays); - $arrayforsort=$address_town; + $arrayforsort = $address_town; } - foreach($arrayforsort as $key=>$value) { + foreach ($arrayforsort as $key=>$value) { print '
    ".$linkname."'; - if (! empty($conf->propal->enabled) && $key>0) { + if (!empty($conf->propal->enabled) && $key > 0) { print ' '.img_picto($langs->trans("ProposalStats"), "stats").' '; } - if (! empty($conf->commande->enabled) && $key>0) { + if (!empty($conf->commande->enabled) && $key > 0) { print ' '.img_picto($langs->trans("OrderStats"), "stats").' '; } - if (! empty($conf->facture->enabled) && $key>0) { + if (!empty($conf->facture->enabled) && $key > 0) { print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' '; } print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); print ''; print ''; @@ -671,16 +671,16 @@ if (! empty($conf->socialnetworks->enabled)) { } } } -if (! empty($arrayfields['p.thirdparty']['checked'])) +if (!empty($arrayfields['p.thirdparty']['checked'])) { print ''; print ''; print ''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); print $form->selectarray('search_priv', $selectarray, $search_priv, 1); print '
    '; print $obj->rowid; print "'; print $contactstatic->getNomUrl(1, '', 0); print ''.$obj->firstname.''.$obj->poste.''.$obj->zip.''.$obj->town.''; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL').''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18).''.yn($obj->no_email).''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key).''; if ($obj->socid) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 57bbf9eb54d..e5aa9cbe4bb 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -27,24 +27,24 @@ * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! isset($mode) || $mode != 'noajax') // For ajax call +if (!isset($mode) || $mode != 'noajax') // For ajax call { require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - $action=GETPOST('action', 'aZ09'); - $file=urldecode(GETPOST('file', 'alpha')); - $section=GETPOST("section", 'alpha'); - $module=GETPOST("module", 'alpha'); - $urlsource=GETPOST("urlsource", 'alpha'); - $search_doc_ref=GETPOST('search_doc_ref', 'alpha'); + $action = GETPOST('action', 'aZ09'); + $file = urldecode(GETPOST('file', 'alpha')); + $section = GETPOST("section", 'alpha'); + $module = GETPOST("module", 'alpha'); + $urlsource = GETPOST("urlsource", 'alpha'); + $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -53,16 +53,16 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="name"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "name"; $rootdirfordoc = $conf->ecm->dir_output; $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); $ecmdir = new EcmDirectory($db); - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { //dol_print_error($db,$ecmdir->error); //exit; @@ -73,21 +73,21 @@ else // For no ajax call $rootdirfordoc = $conf->ecm->dir_output; $ecmdir = new EcmDirectory($db); - $relativepath=''; + $relativepath = ''; if ($section > 0) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } - $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' + $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' } elseif (GETPOST('section_dir')) { - $relativepath=GETPOST('section_dir'); + $relativepath = GETPOST('section_dir'); } //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); @@ -96,12 +96,12 @@ else // For no ajax call if (empty($url)) { - if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; - else $url=DOL_URL_ROOT.'/ecm/index.php'; + if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php'; + else $url = DOL_URL_ROOT.'/ecm/index.php'; } // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other")); +$langs->loadLangs(array("ecm", "companies", "other")); // Security check if ($user->socid > 0) $socid = $user->socid; @@ -121,7 +121,7 @@ if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) // Check permissions if ($modulepart == 'ecm') { - if (! $user->rights->ecm->read) accessforbidden(); + if (!$user->rights->ecm->read) accessforbidden(); } if ($modulepart == 'medias') { @@ -141,7 +141,7 @@ if ($modulepart == 'medias') * View */ -if (! isset($mode) || $mode != 'noajax') +if (!isset($mode) || $mode != 'noajax') { // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); @@ -150,10 +150,10 @@ if (! isset($mode) || $mode != 'noajax') top_httphead(); } -$type='directory'; +$type = 'directory'; // This test if file exists should be useless. We keep it to find bug more easily -if (! dol_is_dir($upload_dir)) +if (!dol_is_dir($upload_dir)) { //dol_mkdir($upload_dir); /*$langs->load("install"); @@ -164,19 +164,19 @@ if (! dol_is_dir($upload_dir)) print ''."\n"; //print ''."\n"; -$param=($sortfield?'&sortfield='.urlencode($sortfield):'').($sortorder?'&sortorder='.urlencode($sortorder):''); -if (! empty($websitekey)) $param.='&website='.urlencode($websitekey); -if (! empty($pageid)) $param.='&pageid='.urlencode($pageid); +$param = ($sortfield ? '&sortfield='.urlencode($sortfield) : '').($sortorder ? '&sortorder='.urlencode($sortorder) : ''); +if (!empty($websitekey)) $param .= '&website='.urlencode($websitekey); +if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid); // Dir scan if ($type == 'directory') { - $formfile=new FormFile($db); + $formfile = new FormFile($db); - $maxlengthname=40; - $excludefiles = array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview.*\.png)$','^temp$','^payments$','^CVS$','^thumbs$'); - $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); + $maxlengthname = 40; + $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); + $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); // Right area. If module is defined here, we are in automatic ecm. $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday', 'banque'); @@ -218,17 +218,17 @@ if ($type == 'directory') // Automatic list if (in_array($module, $automodules)) { - $param.='&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.urlencode($search_doc_ref); + $param .= '&module='.$module; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref); - $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); + $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - $filter=preg_quote($search_doc_ref, '/'); - $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); + $filter = preg_quote($search_doc_ref, '/'); + $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); - $perm=$user->rights->ecm->upload; + $perm = $user->rights->ecm->upload; $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); } @@ -248,84 +248,84 @@ if ($type == 'directory') 'max_file_size' => string '2097152' (length=7) 'sendit' => string 'Envoyer fichier' (length=15) */ - $relativepath=GETPOST('file', 'alpha')?GETPOST('file', 'alpha'):GETPOST('section_dir', 'alpha'); - if ($relativepath && $relativepath!= '/') $relativepath.='/'; + $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); + if ($relativepath && $relativepath != '/') $relativepath .= '/'; $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) { - $param.='&file_manager=1'; - if (!preg_match('/website=/', $param)) $param.='&website='.urlencode(GETPOST('website', 'alpha')); - if (!preg_match('/pageid=/', $param)) $param.='&pageid='.urlencode(GETPOST('pageid', 'int')); + $param .= '&file_manager=1'; + if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); + if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); } } else { - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } // If $section defined with value 0 if (($section === '0' || empty($section)) && ($module != 'medias')) { - $filearray=array(); + $filearray = array(); } else { - $filearray=dol_dir_list($upload_dir, "files", 0, '', array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'), $sortfield, $sorting, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); } if ($section) { - $param.='§ion='.$section; - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; + $param .= '§ion='.$section; + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; $textifempty = $langs->trans('NoFileFound'); } elseif ($section === '0') { - if ($module == 'ecm') $textifempty='
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; + if ($module == 'ecm') $textifempty = '
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; else $textifempty = $langs->trans('NoFileFound'); } - else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); + else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); if ($module == 'medias') { $useinecm = 6; - $modulepart='medias'; - $perm=($user->rights->website->write || $user->rights->emailing->creer); - $title='none'; + $modulepart = 'medias'; + $perm = ($user->rights->website->write || $user->rights->emailing->creer); + $title = 'none'; } - elseif($module == 'ecm') // DMS/ECM -> manual structure + elseif ($module == 'ecm') // DMS/ECM -> manual structure { - if($user->rights->ecm->read) + if ($user->rights->ecm->read) { // Buttons: Preview $useinecm = 2; } - if($user->rights->ecm->upload) + if ($user->rights->ecm->upload) { // Buttons: Preview + Delete $useinecm = 4; } - if($user->rights->ecm->setup) + if ($user->rights->ecm->setup) { // Buttons: Preview + Delete + Edit $useinecm = 5; } - $perm=$user->rights->ecm->upload; - $modulepart='ecm'; - $title=''; // Use default + $perm = $user->rights->ecm->upload; + $modulepart = 'ecm'; + $title = ''; // Use default } else { $useinecm = 5; - $modulepart='ecm'; - $perm=$user->rights->ecm->upload; - $title=''; // Use default + $modulepart = 'ecm'; + $perm = $user->rights->ecm->upload; + $title = ''; // Use default } // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param @@ -338,33 +338,33 @@ if ($type == 'directory') // Bottom of page -$useajax=1; -if (! empty($conf->dol_use_jmobile)) $useajax=0; -if (empty($conf->use_javascript_ajax)) $useajax=0; -if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; +$useajax = 1; +if (!empty($conf->dol_use_jmobile)) $useajax = 0; +if (empty($conf->use_javascript_ajax)) $useajax = 0; +if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); if ($useajax || $action == 'delete') { - $urlfile=''; - if ($action == 'delete') $urlfile=GETPOST('urlfile', 'alpha'); + $urlfile = ''; + if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha'); - if (empty($section_dir)) $section_dir=GETPOST("file", "alpha"); - $section_id=$section; + if (empty($section_dir)) $section_dir = GETPOST("file", "alpha"); + $section_id = $section; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $useglobalvars=1; + $useglobalvars = 1; $form = new Form($db); - $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later - $formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later - $formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later - $formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later - if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager'); - if (! empty($websitekey)) $formquestion['website'] =array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); - if (! empty($pageid) && $pageid > 0) $formquestion['pageid'] =array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); + $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later + $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later + $formquestion['section_id'] = array('type'=>'hidden', 'value'=>$section_id, 'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later + $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later + if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); + if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); + if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); - print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax?'deletefile':0)); + print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0)); } if ($useajax) @@ -402,4 +402,4 @@ if ($useajax) } // Close db if mode is not noajax -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 1870d0a7d88..04687b77829 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -26,14 +26,14 @@ // This script is called with a POST method. // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! isset($mode) || $mode != 'noajax') // For ajax call +if (!isset($mode) || $mode != 'noajax') // For ajax call { - $res=@include '../../main.inc.php'; + $res = @include '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; @@ -43,41 +43,41 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } $openeddir = GETPOST('openeddir'); - $modulepart= GETPOST('modulepart'); - $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() + $modulepart = GETPOST('modulepart'); + $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() $preopened = GETPOST('preopened'); - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' } else // For no ajax call { //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } $openeddir = GETPOST('openeddir'); - $modulepart= GETPOST('modulepart'); + $modulepart = GETPOST('modulepart'); $selecteddir = GETPOST('dir'); $preopened = GETPOST('preopened'); - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' - if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' + if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php'; } // Load translation files required by the page $langs->load("ecm"); // Define fullpathselecteddir. -$fullpathselecteddir=''; +$fullpathselecteddir = ''; if ($modulepart == 'ecm') { - $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); - $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); + $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); + $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); } elseif ($modulepart == 'medias') { - $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); - $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); + $fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); + $fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); } @@ -94,7 +94,7 @@ if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpat // Check permissions if ($modulepart == 'ecm') { - if (! $user->rights->ecm->read) accessforbidden(); + if (!$user->rights->ecm->read) accessforbidden(); } elseif ($modulepart == 'medias') { @@ -106,22 +106,22 @@ elseif ($modulepart == 'medias') * View */ -if (! isset($mode) || $mode != 'noajax') // if ajax mode +if (!isset($mode) || $mode != 'noajax') // if ajax mode { top_httphead(); } //print ''."\n"; -$userstatic=new User($db); -$form=new Form($db); +$userstatic = new User($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir -if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); +if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id -$current_ecmdir_id=-1; -foreach($sqltree as $keycursor => $val) +$current_ecmdir_id = -1; +foreach ($sqltree as $keycursor => $val) { //print $val['fullrelativename']." == ".$selecteddir; if ($val['fullrelativename'] == $selecteddir) @@ -130,7 +130,7 @@ foreach($sqltree as $keycursor => $val) } } -if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) +if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); @@ -158,111 +158,111 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE } -if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS)) +if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '
      '; // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir - if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow + if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow // ----- This section will show a tree from a fulltree array ----- // $section must also be defined // ---------------------------------------------------------------- // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree) - $fullpathselected=''; - foreach($sqltree as $key => $val) + $fullpathselected = ''; + foreach ($sqltree as $key => $val) { //print $val['id']."-".$section."
      "; if ($val['id'] == $section) { - $fullpathselected=$val['fullpath']; + $fullpathselected = $val['fullpath']; break; } } //print "fullpathselected=".$fullpathselected."
      "; // Update expandedsectionarray in session - $expandedsectionarray=array(); - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',', $_SESSION['dol_ecmexpandedsectionarray']); + $expandedsectionarray = array(); + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']); if ($section && GETPOST('sectionexpand') == 'true') { // We add all sections that are parent of opened section - $pathtosection=explode('_', $fullpathselected); - foreach($pathtosection as $idcursor) + $pathtosection = explode('_', $fullpathselected); + foreach ($pathtosection as $idcursor) { - if ($idcursor && ! in_array($idcursor, $expandedsectionarray)) // Not already in array + if ($idcursor && !in_array($idcursor, $expandedsectionarray)) // Not already in array { - $expandedsectionarray[]=$idcursor; + $expandedsectionarray[] = $idcursor; } } - $_SESSION['dol_ecmexpandedsectionarray']=join(',', $expandedsectionarray); + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); } if ($section && GETPOST('sectionexpand') == 'false') { // We removed all expanded sections that are child of the closed section - $oldexpandedsectionarray=$expandedsectionarray; - $expandedsectionarray=array(); // Reset - foreach($oldexpandedsectionarray as $sectioncursor) + $oldexpandedsectionarray = $expandedsectionarray; + $expandedsectionarray = array(); // Reset + foreach ($oldexpandedsectionarray as $sectioncursor) { // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this... //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; } - $_SESSION['dol_ecmexpandedsectionarray']=join(',', $expandedsectionarray); + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); } //print $_SESSION['dol_ecmexpandedsectionarray'].'
      '; - $nbofentries=0; - $oldvallevel=0; - foreach($sqltree as $key => $val) + $nbofentries = 0; + $oldvallevel = 0; + foreach ($sqltree as $key => $val) { - $ecmdirstatic->id=$val['id']; - $ecmdirstatic->ref=$val['label']; + $ecmdirstatic->id = $val['id']; + $ecmdirstatic->ref = $val['label']; // Refresh cache if (preg_match('/refresh/i', $action)) { - $result=$ecmdirstatic->fetch($val['id']); - $ecmdirstatic->ref=$ecmdirstatic->label; + $result = $ecmdirstatic->fetch($val['id']); + $ecmdirstatic->ref = $ecmdirstatic->label; - $result=$ecmdirstatic->refreshcachenboffile(0); - $val['cachenbofdoc']=$result; + $result = $ecmdirstatic->refreshcachenboffile(0); + $val['cachenbofdoc'] = $result; } //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); // Define showline - $showline=0; + $showline = 0; // If directory is son of expanded directory, we show line - if (in_array($val['id_mere'], $expandedsectionarray)) $showline=4; + if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4; // If directory is brother of selected directory, we show line - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3; // If directory is parent of selected directory or is selected directory, we show line - elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline=2; + elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2; // If we are level one we show line - elseif ($val['level'] < 2) $showline=1; + elseif ($val['level'] < 2) $showline = 1; if ($showline) { - if (in_array($val['id'], $expandedsectionarray)) $option='indexexpanded'; - else $option='indexnotexpanded'; + if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded'; + else $option = 'indexnotexpanded'; //print $option; print '
    '; - $userstatic->id=$val['fk_user_c']; - $userstatic->lastname=$val['login_c']; - $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
    '; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; - $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; - $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dol_print_date($val['date_c'], "dayhour").'
    '; - $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].'
    '; - $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].'
    '; - if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; - else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.'
    '; + $userstatic->id = $val['fk_user_c']; + $userstatic->lastname = $val['login_c']; + $htmltooltip = ''.$langs->trans("ECMSection").': '.$val['label'].'
    '; + $htmltooltip = ''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; + $htmltooltip .= ''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; + $htmltooltip .= ''.$langs->trans("ECMCreationDate").': '.dol_print_date($val['date_c'], "dayhour").'
    '; + $htmltooltip .= ''.$langs->trans("Description").': '.$val['description'].'
    '; + $htmltooltip .= ''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].'
    '; + if ($nbofsubdir) $htmltooltip .= ''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip .= ''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.'
    '; print $form->textwithpicto('', $htmltooltip, 1, 'info'); print "
    '; - print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; + print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : ' '; print ''; - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '+'.$nboffilesinsubdir.' '; print ''; - $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; - $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; - $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
    '; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; - $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; - $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.(isset($val['date_c'])?dol_print_date($val['date_c'], "dayhour"):$langs->trans("NeedRefresh")).'
    '; - $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].'
    '; - $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'
    '; - if ($nboffilesinsubdir > 0) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; - else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'
    '; + $userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0; + $userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0; + $htmltooltip = ''.$langs->trans("ECMSection").': '.$val['label'].'
    '; + $htmltooltip = ''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
    '; + $htmltooltip .= ''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1, '', false, 1).'
    '; + $htmltooltip .= ''.$langs->trans("ECMCreationDate").': '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'
    '; + $htmltooltip .= ''.$langs->trans("Description").': '.$val['description'].'
    '; + $htmltooltip .= ''.$langs->trans("ECMNbOfFilesInDir").': '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'
    '; + if ($nboffilesinsubdir > 0) $htmltooltip .= ''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip .= ''.$langs->trans("ECMNbOfSubDir").': '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'
    '; print $form->textwithpicto('', $htmltooltip, 1, "info"); print "
    '; - if ($object->photo) $ret.=''; - $ret.=''; - $ret.='
    '.$langs->trans("Delete").'

    '; + if ($object->photo) $ret .= "
    \n"; + $ret .= ''; + if ($object->photo) $ret .= ''; + $ret .= ''; + $ret .= '
    '.$langs->trans("Delete").'

    '; } } else dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart); diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index c7c7682c884..1564fc3f9bc 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -27,31 +27,31 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); require_once '../main.inc.php'; -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php $langs->load("main"); -$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); -$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); /* * View */ -$title=$langs->trans("Info"); +$title = $langs->trans("Info"); // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests -$head=''."\n"; -$arrayofjs=array(); -$arrayofcss=array(); +$head = ''."\n"; +$arrayofjs = array(); +$arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); @@ -60,39 +60,39 @@ print ''."\n"; print '
    '; //print '
    '; -$nbofsearch=0; +$nbofsearch = 0; // Define link to login card -$appli=constant('DOL_APPLICATION_TITLE'); -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) +$appli = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli=$conf->global->MAIN_APPLICATION_TITLE; + $appli = $conf->global->MAIN_APPLICATION_TITLE; if (preg_match('/\d\.\d/', $appli)) { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; } -else $appli.=" ".DOL_VERSION; +else $appli .= " ".DOL_VERSION; -if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="
    ".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; +if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $appli .= "
    ".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; -$logouttext=''; +$logouttext = ''; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$logouthtmltext=$appli.'
    '; if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') { - $logouthtmltext.=$langs->trans("Logout").'
    '; + $logouthtmltext .= $langs->trans("Logout").'
    '; - $logouttext .=''; + $logouttext .= ''; //$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); - $logouttext .=''; - $logouttext .=''; + $logouttext .= ''; + $logouttext .= ''; } else { - $logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]); + $logouthtmltext .= $langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]); $logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); } } @@ -100,36 +100,36 @@ if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '\n"; // end div class="login_block" +print "
    \n"; // end div class="login_block" print '
    '; print ''."\n"; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 288e7058a08..5f0830387f2 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -24,7 +24,7 @@ * \brief Library of admin functions */ -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; /** * Renvoi une version en chaine depuis une version en tableau @@ -35,10 +35,10 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; */ function versiontostring($versionarray) { - $string='?'; - if (isset($versionarray[0])) $string=$versionarray[0]; - if (isset($versionarray[1])) $string.='.'.$versionarray[1]; - if (isset($versionarray[2])) $string.='.'.$versionarray[2]; + $string = '?'; + if (isset($versionarray[0])) $string = $versionarray[0]; + if (isset($versionarray[1])) $string .= '.'.$versionarray[1]; + if (isset($versionarray[2])) $string .= '.'.$versionarray[2]; return $string; } @@ -59,25 +59,25 @@ function versiontostring($versionarray) */ function versioncompare($versionarray1, $versionarray2) { - $ret=0; - $level=0; - $count1=count($versionarray1); - $count2=count($versionarray2); - $maxcount=max($count1, $count2); + $ret = 0; + $level = 0; + $count1 = count($versionarray1); + $count2 = count($versionarray2); + $maxcount = max($count1, $count2); while ($level < $maxcount) { - $operande1=isset($versionarray1[$level])?$versionarray1[$level]:0; - $operande2=isset($versionarray2[$level])?$versionarray2[$level]:0; - if (preg_match('/alpha|dev/i', $operande1)) $operande1=-5; - if (preg_match('/alpha|dev/i', $operande2)) $operande2=-5; - if (preg_match('/beta$/i', $operande1)) $operande1=-4; - if (preg_match('/beta$/i', $operande2)) $operande2=-4; - if (preg_match('/beta([0-9])+/i', $operande1)) $operande1=-3; - if (preg_match('/beta([0-9])+/i', $operande2)) $operande2=-3; - if (preg_match('/rc$/i', $operande1)) $operande1=-2; - if (preg_match('/rc$/i', $operande2)) $operande2=-2; - if (preg_match('/rc([0-9])+/i', $operande1)) $operande1=-1; - if (preg_match('/rc([0-9])+/i', $operande2)) $operande2=-1; + $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0; + $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0; + if (preg_match('/alpha|dev/i', $operande1)) $operande1 = -5; + if (preg_match('/alpha|dev/i', $operande2)) $operande2 = -5; + if (preg_match('/beta$/i', $operande1)) $operande1 = -4; + if (preg_match('/beta$/i', $operande2)) $operande2 = -4; + if (preg_match('/beta([0-9])+/i', $operande1)) $operande1 = -3; + if (preg_match('/beta([0-9])+/i', $operande2)) $operande2 = -3; + if (preg_match('/rc$/i', $operande1)) $operande1 = -2; + if (preg_match('/rc$/i', $operande2)) $operande2 = -2; + if (preg_match('/rc([0-9])+/i', $operande1)) $operande1 = -1; + if (preg_match('/rc([0-9])+/i', $operande2)) $operande2 = -1; $level++; //print 'level '.$level.' '.$operande1.'-'.$operande2.'
    '; if ($operande1 < $operande2) { $ret = -$level; break; } @@ -135,55 +135,55 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler." okerror=".$okerror, LOG_DEBUG); - if (! is_numeric($linelengthlimit)) + if (!is_numeric($linelengthlimit)) { dol_syslog("Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR); return -1; } - $ok=0; - $error=0; - $i=0; + $ok = 0; + $error = 0; + $i = 0; $buffer = ''; $arraysql = array(); // Get version of database - $versionarray=$db->getVersionArray(); + $versionarray = $db->getVersionArray(); $fp = fopen($sqlfile, "r"); if ($fp) { - while (! feof($fp)) + while (!feof($fp)) { // Warning fgets with second parameter that is null or 0 hang. if ($linelengthlimit > 0) $buf = fgets($fp, $linelengthlimit); else $buf = fgets($fp); // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) - $reg=array(); + $reg = array(); if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) { - $qualified=1; + $qualified = 1; // restrict on database type - if (! empty($reg[1])) + if (!empty($reg[1])) { - if (! preg_match('/'.preg_quote($reg[1]).'/i', $db->type)) $qualified=0; + if (!preg_match('/'.preg_quote($reg[1]).'/i', $db->type)) $qualified = 0; } // restrict on version if ($qualified) { - if (! empty($reg[2])) + if (!empty($reg[2])) { if (is_numeric($reg[2])) // This is a version { - $versionrequest=explode('.', $reg[2]); + $versionrequest = explode('.', $reg[2]); //print var_dump($versionrequest); //print var_dump($versionarray); - if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) + if (!count($versionrequest) || !count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) { - $qualified=0; + $qualified = 0; } } else // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE @@ -191,7 +191,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle $dbcollation = strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)); //var_dump($reg[2]); //var_dump($dbcollation); - if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) $qualified=0; + if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) $qualified = 0; //var_dump($qualified); } } @@ -200,15 +200,15 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($qualified) { // Version qualified, delete SQL comments - $buf=preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i', '', $buf); + $buf = preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i', '', $buf); //print "Ligne $i qualifi?e par version: ".$buf.'
    '; } } // Add line buf to buffer if not a comment - if ($nocommentremoval || ! preg_match('/^\s*--/', $buf)) + if ($nocommentremoval || !preg_match('/^\s*--/', $buf)) { - if (empty($nocommentremoval)) $buf=preg_replace('/([,;ERLT\)])\s*--.*$/i', '\1', $buf); //remove comment from a line that not start with -- before add it to the buffer + if (empty($nocommentremoval)) $buf = preg_replace('/([,;ERLT\)])\s*--.*$/i', '\1', $buf); //remove comment from a line that not start with -- before add it to the buffer $buffer .= trim($buf); } @@ -217,13 +217,13 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if (preg_match('/;/', $buffer)) // If string contains ';', it's end of a request string, we save it in arraysql. { // Found new request - if ($buffer) $arraysql[$i]=$buffer; + if ($buffer) $arraysql[$i] = $buffer; $i++; - $buffer=''; + $buffer = ''; } } - if ($buffer) $arraysql[$i]=$buffer; + if ($buffer) $arraysql[$i] = $buffer; fclose($fp); } else @@ -232,42 +232,42 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle } // Loop on each request to see if there is a __+MAX_table__ key - $listofmaxrowid=array(); // This is a cache table - foreach($arraysql as $i => $sql) + $listofmaxrowid = array(); // This is a cache table + foreach ($arraysql as $i => $sql) { - $newsql=$sql; + $newsql = $sql; // Replace __+MAX_table__ with max of table while (preg_match('/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) { - $table=$reg[1]; - if (! isset($listofmaxrowid[$table])) + $table = $reg[1]; + if (!isset($listofmaxrowid[$table])) { //var_dump($db); - $sqlgetrowid='SELECT MAX(rowid) as max from '.preg_replace('/^llx_/', MAIN_DB_PREFIX, $table); - $resql=$db->query($sqlgetrowid); + $sqlgetrowid = 'SELECT MAX(rowid) as max from '.preg_replace('/^llx_/', MAIN_DB_PREFIX, $table); + $resql = $db->query($sqlgetrowid); if ($resql) { - $obj=$db->fetch_object($resql); - $listofmaxrowid[$table]=$obj->max; - if (empty($listofmaxrowid[$table])) $listofmaxrowid[$table]=0; + $obj = $db->fetch_object($resql); + $listofmaxrowid[$table] = $obj->max; + if (empty($listofmaxrowid[$table])) $listofmaxrowid[$table] = 0; } else { - if (! $silent) print ''; - if (! $silent) print '
    '.$langs->trans("Failed to get max rowid for ".$table)."
    "; - if (! $silent) print ''; + if (!$silent) print ''; + if (!$silent) print '
    '.$langs->trans("Failed to get max rowid for ".$table)."
    "; + if (!$silent) print ''; $error++; break; } } // Replace __+MAX_llx_table__ with +999 - $from='__+MAX_'.$table.'__'; - $to='+'.$listofmaxrowid[$table]; - $newsql=str_replace($from, $to, $newsql); - dol_syslog('Admin.lib::run_sql New Request '.($i+1).' (replacing '.$from.' to '.$to.')', LOG_DEBUG); + $from = '__+MAX_'.$table.'__'; + $to = '+'.$listofmaxrowid[$table]; + $newsql = str_replace($from, $to, $newsql); + dol_syslog('Admin.lib::run_sql New Request '.($i + 1).' (replacing '.$from.' to '.$to.')', LOG_DEBUG); - $arraysql[$i]=$newsql; + $arraysql[$i] = $newsql; } if ($offsetforchartofaccount > 0) @@ -284,37 +284,37 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle } // Loop on each request to execute request - $cursorinsert=0; - $listofinsertedrowid=array(); - foreach($arraysql as $i => $sql) + $cursorinsert = 0; + $listofinsertedrowid = array(); + foreach ($arraysql as $i => $sql) { if ($sql) { // Replace the prefix tables if (MAIN_DB_PREFIX != 'llx_') { - $sql=preg_replace('/llx_/i', MAIN_DB_PREFIX, $sql); + $sql = preg_replace('/llx_/i', MAIN_DB_PREFIX, $sql); } - if (!empty($handler)) $sql=preg_replace('/__HANDLER__/i', "'".$handler."'", $sql); + if (!empty($handler)) $sql = preg_replace('/__HANDLER__/i', "'".$handler."'", $sql); - $newsql=preg_replace('/__ENTITY__/i', (!empty($entity)?$entity:$conf->entity), $sql); + $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql); // Ajout trace sur requete (eventuellement a commenter si beaucoup de requetes) - if (! $silent) print ''.$langs->trans("Request").' '.($i+1)." sql='".dol_htmlentities($newsql, ENT_NOQUOTES)."'\n"; - dol_syslog('Admin.lib::run_sql Request '.($i+1), LOG_DEBUG); - $sqlmodified=0; + if (!$silent) print ''.$langs->trans("Request").' '.($i + 1)." sql='".dol_htmlentities($newsql, ENT_NOQUOTES)."'\n"; + dol_syslog('Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG); + $sqlmodified = 0; // Replace for encrypt data if (preg_match_all('/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) { - $num=count($reg[0]); + $num = count($reg[0]); - for($j=0;$j<$num;$j++) + for ($j = 0; $j < $num; $j++) { - $from = $reg[0][$j]; - $to = $db->encrypt($reg[1][$j], 1); - $newsql = str_replace($from, $to, $newsql); + $from = $reg[0][$j]; + $to = $db->encrypt($reg[1][$j], 1); + $newsql = str_replace($from, $to, $newsql); } $sqlmodified++; } @@ -322,13 +322,13 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle // Replace for decrypt data if (preg_match_all('/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) { - $num=count($reg[0]); + $num = count($reg[0]); - for($j=0;$j<$num;$j++) + for ($j = 0; $j < $num; $j++) { - $from = $reg[0][$j]; - $to = $db->decrypt($reg[1][$j]); - $newsql = str_replace($from, $to, $newsql); + $from = $reg[0][$j]; + $to = $db->decrypt($reg[1][$j]); + $newsql = str_replace($from, $to, $newsql); } $sqlmodified++; } @@ -336,88 +336,88 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle // Replace __x__ with rowid of insert nb x while (preg_match('/__([0-9]+)__/', $newsql, $reg)) { - $cursor=$reg[1]; + $cursor = $reg[1]; if (empty($listofinsertedrowid[$cursor])) { - if (! $silent) print ''; - if (! $silent) print '
    '.$langs->trans("FileIsNotCorrect")."
    "; - if (! $silent) print ''; + if (!$silent) print ''; + if (!$silent) print '
    '.$langs->trans("FileIsNotCorrect")."
    "; + if (!$silent) print ''; $error++; break; } - $from='__'.$cursor.'__'; - $to=$listofinsertedrowid[$cursor]; - $newsql=str_replace($from, $to, $newsql); + $from = '__'.$cursor.'__'; + $to = $listofinsertedrowid[$cursor]; + $newsql = str_replace($from, $to, $newsql); $sqlmodified++; } - if ($sqlmodified) dol_syslog('Admin.lib::run_sql New Request '.($i+1), LOG_DEBUG); + if ($sqlmodified) dol_syslog('Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG); - $result=$db->query($newsql, $usesavepoint); + $result = $db->query($newsql, $usesavepoint); if ($result) { - if (! $silent) print ''."\n"; + if (!$silent) print ''."\n"; if (preg_replace('/insert into ([^\s]+)/i', $newsql, $reg)) { $cursorinsert++; // It's an insert - $table=preg_replace('/([^a-zA-Z_]+)/i', '', $reg[1]); - $insertedrowid=$db->last_insert_id($table); - $listofinsertedrowid[$cursorinsert]=$insertedrowid; + $table = preg_replace('/([^a-zA-Z_]+)/i', '', $reg[1]); + $insertedrowid = $db->last_insert_id($table); + $listofinsertedrowid[$cursorinsert] = $insertedrowid; dol_syslog('Admin.lib::run_sql Insert nb '.$cursorinsert.', done in table '.$table.', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG); } // print 'OK'; } else { - $errno=$db->errno(); - if (! $silent) print ''."\n"; + $errno = $db->errno(); + if (!$silent) print ''."\n"; // Define list of errors we accept (array $okerrors) - $okerrors=array( // By default + $okerrors = array( // By default 'DB_ERROR_TABLE_ALREADY_EXISTS', 'DB_ERROR_COLUMN_ALREADY_EXISTS', 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', - 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist + 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist 'DB_ERROR_RECORD_ALREADY_EXISTS', 'DB_ERROR_NOSUCHTABLE', 'DB_ERROR_NOSUCHFIELD', 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', 'DB_ERROR_NO_INDEX_TO_DROP', - 'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante + 'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante 'DB_ERROR_CANT_DROP_PRIMARY_KEY', 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS', 'DB_ERROR_22P02' ); - if ($okerror == 'none') $okerrors=array(); + if ($okerror == 'none') $okerrors = array(); // Is it an error we accept - if (! in_array($errno, $okerrors)) + if (!in_array($errno, $okerrors)) { - if (! $silent) print ''; - if (! $silent) print '
    '.$langs->trans("Error")." ".$db->errno().": ".$newsql."
    ".$db->error()."
    "; - if (! $silent) print ''."\n"; - dol_syslog('Admin.lib::run_sql Request '.($i+1)." Error ".$db->errno()." ".$newsql."
    ".$db->error(), LOG_ERR); + if (!$silent) print ''; + if (!$silent) print '
    '.$langs->trans("Error")." ".$db->errno().": ".$newsql."
    ".$db->error()."
    "; + if (!$silent) print ''."\n"; + dol_syslog('Admin.lib::run_sql Request '.($i + 1)." Error ".$db->errno()." ".$newsql."
    ".$db->error(), LOG_ERR); $error++; } } - if (! $silent) print ''."\n"; + if (!$silent) print ''."\n"; } } if ($error == 0) { - if (! $silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (! $silent) print ''.$langs->trans("OK").''."\n"; + if (!$silent) print ''.$langs->trans("ProcessMigrateScript").''; + if (!$silent) print ''.$langs->trans("OK").''."\n"; $ok = 1; } else { - if (! $silent) print ''.$langs->trans("ProcessMigrateScript").''; - if (! $silent) print ''.$langs->trans("KO").''."\n"; + if (!$silent) print ''.$langs->trans("ProcessMigrateScript").''; + if (!$silent) print ''.$langs->trans("KO").''."\n"; $ok = 0; } @@ -446,16 +446,16 @@ function dolibarr_del_const($db, $name, $entity = 1) } $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE (".$db->decrypt('name')." = '".$db->escape($name)."'"; - if (is_numeric($name)) $sql.= " OR rowid = '".$db->escape($name)."'"; - $sql.= ")"; - if ($entity >= 0) $sql.= " AND entity = ".$entity; + $sql .= " WHERE (".$db->decrypt('name')." = '".$db->escape($name)."'"; + if (is_numeric($name)) $sql .= " OR rowid = '".$db->escape($name)."'"; + $sql .= ")"; + if ($entity >= 0) $sql .= " AND entity = ".$entity; dol_syslog("admin.lib::dolibarr_del_const", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $conf->global->$name=''; + $conf->global->$name = ''; return 1; } else @@ -478,19 +478,19 @@ function dolibarr_del_const($db, $name, $entity = 1) function dolibarr_get_const($db, $name, $entity = 1) { global $conf; - $value=''; + $value = ''; $sql = "SELECT ".$db->decrypt('value')." as value"; - $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE name = ".$db->encrypt($name, 1); - $sql.= " AND entity = ".$entity; + $sql .= " FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE name = ".$db->encrypt($name, 1); + $sql .= " AND entity = ".$entity; dol_syslog("admin.lib::dolibarr_get_const", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if ($obj) $value=$obj->value; + $obj = $db->fetch_object($resql); + if ($obj) $value = $obj->value; } return $value; } @@ -515,7 +515,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, global $conf; // Clean parameters - $name=trim($name); + $name = trim($name); // Check parameters if (empty($name)) @@ -529,35 +529,35 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE name = ".$db->encrypt($name, 1); - if ($entity >= 0) $sql.= " AND entity = ".$entity; + $sql .= " WHERE name = ".$db->encrypt($name, 1); + if ($entity >= 0) $sql .= " AND entity = ".$entity; dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if (strcmp($value, '')) // true if different. Must work for $value='0' or $value=0 { $sql = "INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity)"; - $sql.= " VALUES ("; - $sql.= $db->encrypt($name, 1); - $sql.= ", ".$db->encrypt($value, 1); - $sql.= ",'".$db->escape($type)."',".$visible.",'".$db->escape($note)."',".$entity.")"; + $sql .= " VALUES ("; + $sql .= $db->encrypt($name, 1); + $sql .= ", ".$db->encrypt($value, 1); + $sql .= ",'".$db->escape($type)."',".$visible.",'".$db->escape($note)."',".$entity.")"; //print "sql".$value."-".pg_escape_string($value)."-".$sql;exit; //print "xx".$db->escape($value); dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); } if ($resql) { $db->commit(); - $conf->global->$name=$value; + $conf->global->$name = $value; return 1; } else { - $error=$db->lasterror(); + $error = $db->lasterror(); $db->rollback(); return -1; } @@ -646,13 +646,13 @@ function security_prepare_head() // Show permissions lines - $nbPerms=0; + $nbPerms = 0; $sql = "SELECT COUNT(r.id) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; - $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" - $sql.= " AND entity = ".$conf->entity; - $sql.= " AND bydefault = 1"; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled + $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; + $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND bydefault = 1"; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled $resql = $db->query($sql); if ($resql) { @@ -663,7 +663,7 @@ function security_prepare_head() $head[$h][0] = DOL_URL_ROOT."/admin/perms.php"; $head[$h][1] = $langs->trans("DefaultRights"); - if ($nbPerms > 0) $head[$h][1].= ''.$nbPerms.''; + if ($nbPerms > 0) $head[$h][1] .= ''.$nbPerms.''; $head[$h][2] = 'default'; $h++; @@ -765,7 +765,7 @@ function defaultvalues_prepare_head() $head[$h][2] = 'sortorder'; $h++; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=focus"; $head[$h][1] = $langs->trans("DefaultFocus"); @@ -814,14 +814,14 @@ function listOfSessions() $dh = @opendir(dol_osencode($sessPath)); if ($dh) { - while(($file = @readdir($dh)) !== false) + while (($file = @readdir($dh)) !== false) { if (preg_match('/^sess_/i', $file) && $file != "." && $file != "..") { $fullpath = $sessPath.$file; - if(! @is_dir($fullpath) && is_readable($fullpath)) + if (!@is_dir($fullpath) && is_readable($fullpath)) { - $sessValues = file_get_contents($fullpath); // get raw session data + $sessValues = file_get_contents($fullpath); // get raw session data // Example of possible value //$sessValues = 'newtoken|s:32:"1239f7a0c4b899200fe9ca5ea394f307";dol_loginmesg|s:0:"";newtoken|s:32:"1236457104f7ae0f328c2928973f3cb5";dol_loginmesg|s:0:"";token|s:32:"123615ad8d650c5cc4199b9a1a76783f"; // dol_login|s:5:"admin";dol_authmode|s:8:"dolibarr";dol_tz|s:1:"1";dol_tz_string|s:13:"Europe/Berlin";dol_dst|i:0;dol_dst_observed|s:1:"1";dol_dst_first|s:0:"";dol_dst_second|s:0:"";dol_screenwidth|s:4:"1920"; @@ -831,12 +831,12 @@ function listOfSessions() (preg_match('/dol_entity\|i:'.$conf->entity.';/i', $sessValues) || preg_match('/dol_entity\|s:([0-9]+):"'.$conf->entity.'"/i', $sessValues)) && // limit to current entity preg_match('/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.')"/i', $sessValues)) // limit to company name { - $tmp=explode('_', $file); - $idsess=$tmp[1]; - $regs=array(); + $tmp = explode('_', $file); + $idsess = $tmp[1]; + $regs = array(); $loginfound = preg_match('/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs); if ($loginfound) $arrayofSessions[$idsess]["login"] = $regs[1]; - $arrayofSessions[$idsess]["age"] = time()-filectime($fullpath); + $arrayofSessions[$idsess]["age"] = time() - filectime($fullpath); $arrayofSessions[$idsess]["creation"] = filectime($fullpath); $arrayofSessions[$idsess]["modification"] = filemtime($fullpath); $arrayofSessions[$idsess]["raw"] = $sessValues; @@ -863,28 +863,28 @@ function purgeSessions($mysessionid) $sessPath = ini_get("session.save_path")."/"; dol_syslog('admin.lib:purgeSessions mysessionid='.$mysessionid.' sessPath='.$sessPath); - $error=0; + $error = 0; $dh = @opendir(dol_osencode($sessPath)); - while(($file = @readdir($dh)) !== false) + while (($file = @readdir($dh)) !== false) { if ($file != "." && $file != "..") { $fullpath = $sessPath.$file; - if(! @is_dir($fullpath)) + if (!@is_dir($fullpath)) { - $sessValues = file_get_contents($fullpath); // get raw session data + $sessValues = file_get_contents($fullpath); // get raw session data if (preg_match('/dol_login/i', $sessValues) && // limit to dolibarr session preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues) && // limit to current entity preg_match('/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.')"/i', $sessValues)) // limit to company name { - $tmp=explode('_', $file); - $idsess=$tmp[1]; + $tmp = explode('_', $file); + $idsess = $tmp[1]; // We remove session if it's not ourself if ($idsess != $mysessionid) { - $res=@unlink($fullpath); - if (! $res) $error++; + $res = @unlink($fullpath); + if (!$res) $error++; } } } @@ -892,7 +892,7 @@ function purgeSessions($mysessionid) } @closedir($dh); - if (! $error) return 1; + if (!$error) return 1; else return -$error; } @@ -909,7 +909,7 @@ function activateModule($value, $withdeps = 1) { global $db, $langs, $conf, $mysoc; - $ret=array(); + $ret = array(); // Check parameters if (empty($value)) { @@ -917,20 +917,20 @@ function activateModule($value, $withdeps = 1) return $ret; } - $ret=array('nbmodules'=>0, 'errors'=>array(), 'nbperms'=>0); + $ret = array('nbmodules'=>0, 'errors'=>array(), 'nbperms'=>0); $modName = $value; - $modFile = $modName . ".class.php"; + $modFile = $modName.".class.php"; // Loop on each directory to fill $modulesdir $modulesdir = dolGetModulesDirs(); // Loop on each modulesdir directories - $found=false; + $found = false; foreach ($modulesdir as $dir) { if (file_exists($dir.$modFile)) { - $found=@include_once $dir.$modFile; + $found = @include_once $dir.$modFile; if ($found) break; } } @@ -938,16 +938,16 @@ function activateModule($value, $withdeps = 1) $objMod = new $modName($db); // Test if PHP version ok - $verphp=versionphparray(); - $vermin=isset($objMod->phpmin)?$objMod->phpmin:0; + $verphp = versionphparray(); + $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0; if (is_array($vermin) && versioncompare($verphp, $vermin) < 0) { $ret['errors'][] = $langs->trans("ErrorModuleRequirePHPVersion", versiontostring($vermin)); return $ret; } // Test if Dolibarr version ok - $verdol=versiondolibarrarray(); - $vermin=isset($objMod->need_dolibarr_version)?$objMod->need_dolibarr_version:0; + $verdol = versiondolibarrarray(); + $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0; //print 'version: '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit; if (is_array($vermin) && versioncompare($verdol, $vermin) < 0) { $ret['errors'][] = $langs->trans("ErrorModuleRequireDolibarrVersion", versiontostring($vermin)); @@ -961,28 +961,28 @@ function activateModule($value, $withdeps = 1) } $const_name = $objMod->const_name; - if(!empty($conf->global->$const_name)){ + if (!empty($conf->global->$const_name)) { return $ret; } - $result=$objMod->init(); // Enable module + $result = $objMod->init(); // Enable module if ($result <= 0) { - $ret['errors'][]=$objMod->error; + $ret['errors'][] = $objMod->error; } else { if ($withdeps) { - if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends)) + if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) { // Activation of modules this module depends on // this->depends may be array('modModule1', 'mmodModule2') or array('always1'=>"modModule1", 'FR'=>'modModule2') foreach ($objMod->depends as $key => $modulestring) { //var_dump((! is_numeric($key)) && ! preg_match('/^always/', $key) && $mysoc->country_code && ! preg_match('/^'.$mysoc->country_code.'/', $key));exit; - if ((! is_numeric($key)) && ! preg_match('/^always/', $key) && $mysoc->country_code && ! preg_match('/^'.$mysoc->country_code.'/', $key)) + if ((!is_numeric($key)) && !preg_match('/^always/', $key) && $mysoc->country_code && !preg_match('/^'.$mysoc->country_code.'/', $key)) { dol_syslog("We are not concerned by dependency with key=".$key." because our country is ".$mysoc->country_code); continue; @@ -993,10 +993,10 @@ function activateModule($value, $withdeps = 1) if (file_exists($dir.$modulestring.".class.php")) { $resarray = activateModule($modulestring); - if (empty($resarray['errors'])){ + if (empty($resarray['errors'])) { $activate = true; - }else{ - foreach ($resarray['errors'] as $errorMessage){ + } else { + foreach ($resarray['errors'] as $errorMessage) { dol_syslog($errorMessage, LOG_ERR); } } @@ -1006,8 +1006,8 @@ function activateModule($value, $withdeps = 1) if ($activate) { - $ret['nbmodules']+=$resarray['nbmodules']; - $ret['nbperms']+=$resarray['nbperms']; + $ret['nbmodules'] += $resarray['nbmodules']; + $ret['nbperms'] += $resarray['nbperms']; } else { @@ -1016,7 +1016,7 @@ function activateModule($value, $withdeps = 1) } } - if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit $num = count($objMod->conflictwith); @@ -1034,10 +1034,10 @@ function activateModule($value, $withdeps = 1) } } - if (! count($ret['errors'])) + if (!count($ret['errors'])) { $ret['nbmodules']++; - $ret['nbperms']+=count($objMod->rights); + $ret['nbperms'] += count($objMod->rights); } return $ret; @@ -1058,20 +1058,20 @@ function unActivateModule($value, $requiredby = 1) // Check parameters if (empty($value)) return 'ErrorBadParameter'; - $ret=''; + $ret = ''; $modName = $value; - $modFile = $modName . ".class.php"; + $modFile = $modName.".class.php"; // Loop on each directory to fill $modulesdir $modulesdir = dolGetModulesDirs(); // Loop on each modulesdir directories - $found=false; + $found = false; foreach ($modulesdir as $dir) { if (file_exists($dir.$modFile)) { - $found=@include_once $dir.$modFile; + $found = @include_once $dir.$modFile; if ($found) break; } } @@ -1079,8 +1079,8 @@ function unActivateModule($value, $requiredby = 1) if ($found) { $objMod = new $modName($db); - $result=$objMod->remove(); - if ($result <= 0) $ret=$objMod->error; + $result = $objMod->remove(); + if ($result <= 0) $ret = $objMod->error; } else // We come here when we try to unactivate a module when module does not exists anymore in sources { @@ -1088,17 +1088,17 @@ function unActivateModule($value, $requiredby = 1) // TODO Replace this after DolibarrModules is moved as abstract class with a try catch to show module we try to disable has not been found or could not be loaded include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; $genericMod = new DolibarrModules($db); - $genericMod->name=preg_replace('/^mod/i', '', $modName); - $genericMod->rights_class=strtolower(preg_replace('/^mod/i', '', $modName)); - $genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', $modName)); - dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName); + $genericMod->name = preg_replace('/^mod/i', '', $modName); + $genericMod->rights_class = strtolower(preg_replace('/^mod/i', '', $modName)); + $genericMod->const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', $modName)); + dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name ".$modName); $genericMod->remove(''); } // Disable modules that depends on module we disable - if (! $ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) + if (!$ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) { - $countrb=count($objMod->requiredby); + $countrb = count($objMod->requiredby); for ($i = 0; $i < $countrb; $i++) { //var_dump($objMod->requiredby[$i]); @@ -1144,13 +1144,13 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
    "; dol_syslog("Scan directory ".$dir." for modules"); - $handle=@opendir(dol_osencode($dir)); + $handle = @opendir(dol_osencode($dir)); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
    "; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); @@ -1168,14 +1168,14 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab $j = 1000 + $i; } - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0; - if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0; + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->$const_name) $modulequalified = 0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->$const_name) $modulequalified = 0; //If module is not activated disqualified - if (empty($conf->global->$const_name)) $modulequalified=0; + if (empty($conf->global->$const_name)) $modulequalified = 0; if ($modulequalified) { @@ -1187,23 +1187,23 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab } // Complete the arrays &$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond - if (empty($objMod->dictionaries) && ! empty($objMod->dictionnaries)) $objMod->dictionaries=$objMod->dictionnaries; // For backward compatibility + if (empty($objMod->dictionaries) && !empty($objMod->dictionnaries)) $objMod->dictionaries = $objMod->dictionnaries; // For backward compatibility - if (! empty($objMod->dictionaries)) + if (!empty($objMod->dictionaries)) { //var_dump($objMod->dictionaries['tabname']); - $nbtabname=$nbtablib=$nbtabsql=$nbtabsqlsort=$nbtabfield=$nbtabfieldvalue=$nbtabfieldinsert=$nbtabrowid=$nbtabcond=$nbtabfieldcheck=$nbtabhelp=0; - foreach($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = max($taborder)+1; $tabname[] = $val; } // Position - foreach($objMod->dictionaries['tablib'] as $val) { $nbtablib++; $tablib[] = $val; } - foreach($objMod->dictionaries['tabsql'] as $val) { $nbtabsql++; $tabsql[] = $val; } - foreach($objMod->dictionaries['tabsqlsort'] as $val) { $nbtabsqlsort++; $tabsqlsort[] = $val; } - foreach($objMod->dictionaries['tabfield'] as $val) { $nbtabfield++; $tabfield[] = $val; } - foreach($objMod->dictionaries['tabfieldvalue'] as $val) { $nbtabfieldvalue++; $tabfieldvalue[] = $val; } - foreach($objMod->dictionaries['tabfieldinsert'] as $val) { $nbtabfieldinsert++; $tabfieldinsert[] = $val; } - foreach($objMod->dictionaries['tabrowid'] as $val) { $nbtabrowid++; $tabrowid[] = $val; } - foreach($objMod->dictionaries['tabcond'] as $val) { $nbtabcond++; $tabcond[] = $val; } - if (! empty($objMod->dictionaries['tabhelp'])) foreach($objMod->dictionaries['tabhelp'] as $val) { $nbtabhelp++; $tabhelp[] = $val; } - if (! empty($objMod->dictionaries['tabfieldcheck'])) foreach($objMod->dictionaries['tabfieldcheck'] as $val) { $nbtabfieldcheck++; $tabfieldcheck[] = $val; } + $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0; + foreach ($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = max($taborder) + 1; $tabname[] = $val; } // Position + foreach ($objMod->dictionaries['tablib'] as $val) { $nbtablib++; $tablib[] = $val; } + foreach ($objMod->dictionaries['tabsql'] as $val) { $nbtabsql++; $tabsql[] = $val; } + foreach ($objMod->dictionaries['tabsqlsort'] as $val) { $nbtabsqlsort++; $tabsqlsort[] = $val; } + foreach ($objMod->dictionaries['tabfield'] as $val) { $nbtabfield++; $tabfield[] = $val; } + foreach ($objMod->dictionaries['tabfieldvalue'] as $val) { $nbtabfieldvalue++; $tabfieldvalue[] = $val; } + foreach ($objMod->dictionaries['tabfieldinsert'] as $val) { $nbtabfieldinsert++; $tabfieldinsert[] = $val; } + foreach ($objMod->dictionaries['tabrowid'] as $val) { $nbtabrowid++; $tabrowid[] = $val; } + foreach ($objMod->dictionaries['tabcond'] as $val) { $nbtabcond++; $tabcond[] = $val; } + if (!empty($objMod->dictionaries['tabhelp'])) foreach ($objMod->dictionaries['tabhelp'] as $val) { $nbtabhelp++; $tabhelp[] = $val; } + if (!empty($objMod->dictionaries['tabfieldcheck'])) foreach ($objMod->dictionaries['tabfieldcheck'] as $val) { $nbtabfieldcheck++; $tabfieldcheck[] = $val; } if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) { @@ -1212,7 +1212,7 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab } else { - $taborder[] = 0; // Add an empty line + $taborder[] = 0; // Add an empty line } } @@ -1252,12 +1252,12 @@ function activateModulesRequiredByCountry($country_code) { // Load modules attributes in arrays (name, numero, orders) from dir directory dol_syslog("Scan directory ".$dir." for modules"); - $handle=@opendir(dol_osencode($dir)); + $handle = @opendir(dol_osencode($dir)); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); @@ -1266,14 +1266,14 @@ function activateModulesRequiredByCountry($country_code) include_once $dir.$file; $objMod = new $modName($db); - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - if(!empty($conf->global->$const_name)) $modulequalified=0; // already activated + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if (!empty($conf->global->$const_name)) $modulequalified = 0; // already activated if ($modulequalified) { @@ -1329,13 +1329,13 @@ function complete_elementList_with_modules(&$elementList) // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
    "; dol_syslog("Scan directory ".$dir." for modules"); - $handle=@opendir(dol_osencode($dir)); + $handle = @opendir(dol_osencode($dir)); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
    "; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); @@ -1353,33 +1353,33 @@ function complete_elementList_with_modules(&$elementList) $j = 1000 + $i; } - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0; - if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0; + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->$const_name) $modulequalified = 0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->$const_name) $modulequalified = 0; //If module is not activated disqualified - if (empty($conf->global->$const_name)) $modulequalified=0; + if (empty($conf->global->$const_name)) $modulequalified = 0; if ($modulequalified) { // Load languages files of module if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { - foreach($objMod->langfiles as $langfile) + foreach ($objMod->langfiles as $langfile) { $langs->load($langfile); } } $modules[$i] = $objMod; - $filename[$i]= $modName; - $orders[$i] = $objMod->family."_".$j; // Sort on family then module number + $filename[$i] = $modName; + $orders[$i] = $objMod->family."_".$j; // Sort on family then module number $dirmod[$i] = $dir; //print "x".$modName." ".$orders[$i]."\n
    "; - if (! empty($objMod->module_parts['contactelement'])) + if (!empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); } @@ -1415,12 +1415,12 @@ function complete_elementList_with_modules(&$elementList) */ function form_constantes($tableau, $strictw3c = 0, $helptext = '') { - global $db,$langs,$conf,$user; + global $db, $langs, $conf, $user; global $_Avery_Labels; $form = new Form($db); - if (! empty($strictw3c) && $strictw3c == 1) + if (!empty($strictw3c) && $strictw3c == 1) { print "\n".''; print ''; @@ -1437,10 +1437,10 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') if (empty($strictw3c)) print ''.$langs->trans("Action").''; print "\n"; - $label=''; - foreach($tableau as $key => $const) // Loop on each param + $label = ''; + foreach ($tableau as $key => $const) // Loop on each param { - $label=''; + $label = ''; // $const is a const key like 'MYMODULE_ABC' if (is_numeric($key)) { // Very old behaviour $type = 'string'; @@ -1461,25 +1461,25 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') } $sql = "SELECT "; - $sql.= "rowid"; - $sql.= ", ".$db->decrypt('name')." as name"; - $sql.= ", ".$db->decrypt('value')." as value"; - $sql.= ", type"; - $sql.= ", note"; - $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE ".$db->decrypt('name')." = '".$db->escape($const)."'"; - $sql.= " AND entity IN (0, ".$conf->entity.")"; - $sql.= " ORDER BY name ASC, entity DESC"; + $sql .= "rowid"; + $sql .= ", ".$db->decrypt('name')." as name"; + $sql .= ", ".$db->decrypt('value')." as value"; + $sql .= ", type"; + $sql .= ", note"; + $sql .= " FROM ".MAIN_DB_PREFIX."const"; + $sql .= " WHERE ".$db->decrypt('name')." = '".$db->escape($const)."'"; + $sql .= " AND entity IN (0, ".$conf->entity.")"; + $sql .= " ORDER BY name ASC, entity DESC"; $result = $db->query($sql); dol_syslog("List params", LOG_DEBUG); if ($result) { - $obj = $db->fetch_object($result); // Take first result of select + $obj = $db->fetch_object($result); // Take first result of select if (empty($obj)) // If not yet into table { - $obj = (object) array('rowid'=>'','name'=>$const,'value'=>'','type'=>$type,'note'=>''); + $obj = (object) array('rowid'=>'', 'name'=>$const, 'value'=>'', 'type'=>$type, 'note'=>''); } if (empty($strictw3c)) @@ -1493,10 +1493,10 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') // Show constant print ''; if (empty($strictw3c)) print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ($label ? $label : $langs->trans('Desc'.$const)); @@ -1536,55 +1536,55 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') print ''; // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; - $arrayoflabels=array(); - foreach(array_keys($_Avery_Labels) as $codecards) + $arrayoflabels = array(); + foreach (array_keys($_Avery_Labels) as $codecards) { - $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; + $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name']; } - print $form->selectarray('constvalue'.(empty($strictw3c)?'':'[]'), $arrayoflabels, ($obj->value?$obj->value:'CARD'), 1, 0, 0); + print $form->selectarray('constvalue'.(empty($strictw3c) ? '' : '[]'), $arrayoflabels, ($obj->value ? $obj->value : 'CARD'), 1, 0, 0); print ''; - print ''; + print ''; print ''; } else { print ''; - print ''; - print ''; - if ($obj->type == 'textarea' || in_array($const, array('ADHERENT_CARD_TEXT','ADHERENT_CARD_TEXT_RIGHT','ADHERENT_ETIQUETTE_TEXT'))) + print ''; + print ''; + if ($obj->type == 'textarea' || in_array($const, array('ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT', 'ADHERENT_ETIQUETTE_TEXT'))) { - print '\n"; } elseif ($obj->type == 'html') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('constvalue_'.$const.(empty($strictw3c)?'':'[]'), $obj->value, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('constvalue_'.$const.(empty($strictw3c) ? '' : '[]'), $obj->value, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($obj->type == 'yesno') { - print $form->selectyesno('constvalue'.(empty($strictw3c)?'':'[]'), $obj->value, 1); + print $form->selectyesno('constvalue'.(empty($strictw3c) ? '' : '[]'), $obj->value, 1); } elseif (preg_match('/emailtemplate/', $obj->type)) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $tmp=explode(':', $obj->type); + $tmp = explode(':', $obj->type); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, -1); // We set lang=null to get in priority record with no lang + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, -1); // We set lang=null to get in priority record with no lang //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayofmessagename=array(); + $arrayofmessagename = array(); if (is_array($formmail->lines_model)) { - foreach($formmail->lines_model as $modelmail) + foreach ($formmail->lines_model as $modelmail) { //var_dump($modelmail); - $moreonlabel=''; - if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; - $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; + $moreonlabel = ''; + if (!empty($arrayofmessagename[$modelmail->label])) $moreonlabel = ' ('.$langs->trans("SeveralLangugeVariatFound").')'; + $arrayofmessagename[$modelmail->label] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; } } //var_dump($arraydefaultmessage); @@ -1593,7 +1593,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') } else // type = 'string' ou 'chaine' { - print ''; + print ''; } print ''; } @@ -1611,7 +1611,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') } print ''; - if (! empty($strictw3c) && $strictw3c == 1) + if (!empty($strictw3c) && $strictw3c == 1) { print '
    '; print "
    \n"; @@ -1627,24 +1627,24 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '') */ function showModulesExludedForExternal($modules) { - global $conf,$langs; + global $conf, $langs; - $text=$langs->trans("OnlyFollowingModulesAreOpenedToExternalUsers"); - $listofmodules=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $i=0; + $text = $langs->trans("OnlyFollowingModulesAreOpenedToExternalUsers"); + $listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $i = 0; if (!empty($modules)) { - foreach($modules as $module) + foreach ($modules as $module) { - $moduleconst=$module->const_name; - $modulename=strtolower($module->name); + $moduleconst = $module->const_name; + $modulename = strtolower($module->name); //print 'modulename='.$modulename; //if (empty($conf->global->$moduleconst)) continue; - if (! in_array($modulename, $listofmodules)) continue; + if (!in_array($modulename, $listofmodules)) continue; //var_dump($modulename.' - '.$langs->trans('Module'.$module->numero.'Name')); - if ($i > 0) $text.=', '; - else $text.=' '; + if ($i > 0) $text .= ', '; + else $text .= ' '; $i++; $text .= $langs->trans('Module'.$module->numero.'Name'); } @@ -1669,13 +1669,13 @@ function addDocumentModel($name, $type, $label = '', $description = '') $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($name)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); - $sql.= ")"; + $sql .= " VALUES ('".$db->escape($name)."','".$type."',".$conf->entity.", "; + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; + $sql .= (!empty($description) ? "'".$db->escape($description)."'" : "null"); + $sql .= ")"; dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $db->commit(); @@ -1703,12 +1703,12 @@ function delDocumentModel($name, $type) $db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom = '".$db->escape($name)."'"; - $sql.= " AND type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE nom = '".$db->escape($name)."'"; + $sql .= " AND type = '".$type."'"; + $sql .= " AND entity = ".$conf->entity; dol_syslog("admin.lib::delDocumentModel", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $db->commit(); @@ -1733,9 +1733,9 @@ function phpinfo_array() ob_start(); phpinfo(); $info_arr = array(); - $info_lines = explode("\n", strip_tags(ob_get_clean(), "

    ")); // end of ob_start() + $info_lines = explode("\n", strip_tags(ob_get_clean(), "

    ")); // end of ob_start() $cat = "General"; - foreach($info_lines as $line) + foreach ($info_lines as $line) { // new cat? $title = array(); @@ -1745,7 +1745,7 @@ function phpinfo_array() { $info_arr[trim($cat)][trim($val[1])] = $val[2]; } - elseif(preg_match("~]+>([^<]*)]+>([^<]*)]+>([^<]*)~", $line, $val)) + elseif (preg_match("~]+>([^<]*)]+>([^<]*)]+>([^<]*)~", $line, $val)) { $info_arr[trim($cat)][trim($val[1])] = array("local" => $val[2], "master" => $val[3]); } @@ -1797,7 +1797,7 @@ function email_admin_prepare_head() $h = 0; $head = array(); - if (! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) + if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { $head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; $head[$h][1] = $langs->trans("OutGoingEmailSetup"); @@ -1818,7 +1818,7 @@ function email_admin_prepare_head() $head[$h][2] = 'templates'; $h++; - if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && ! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) + if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && !empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { $head[$h][0] = DOL_URL_ROOT."/admin/mails_senderprofile_list.php"; $head[$h][1] = $langs->trans("EmailSenderProfiles"); diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index 6e9fd42b932..038791ce1cc 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -35,7 +35,7 @@ function ldap_prepare_head() $langs->load("ldap"); // Onglets - $head=array(); + $head = array(); $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/ldap.php"; @@ -43,7 +43,7 @@ function ldap_prepare_head() $head[$h][2] = 'ldap'; $h++; - if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php"; $head[$h][1] = $langs->trans("LDAPUsersSynchro"); @@ -51,7 +51,7 @@ function ldap_prepare_head() $h++; } - if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php"; $head[$h][1] = $langs->trans("LDAPGroupsSynchro"); @@ -59,7 +59,7 @@ function ldap_prepare_head() $h++; } - if (! empty($conf->societe->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) + if (!empty($conf->societe->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php"; $head[$h][1] = $langs->trans("LDAPContactsSynchro"); @@ -67,7 +67,7 @@ function ldap_prepare_head() $h++; } - if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php"; $head[$h][1] = $langs->trans("LDAPMembersSynchro"); @@ -75,7 +75,7 @@ function ldap_prepare_head() $h++; } - if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) + if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php"; $head[$h][1] = $langs->trans("LDAPMembersTypesSynchro"); @@ -109,7 +109,7 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass) //print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass; print '
    '; - if (! function_exists("ldap_connect")) + if (!function_exists("ldap_connect")) { print ''.$butlabel.''; } @@ -146,35 +146,35 @@ function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = global $bc, $conf; $count--; - if ($count == 0) return -1; // To stop loop - if (! is_array($result)) return -1; + if ($count == 0) return -1; // To stop loop + if (!is_array($result)) return -1; - foreach($result as $key => $val) + foreach ($result as $key => $val) { if ("$key" == "objectclass") continue; if ("$key" == "count") continue; if ("$key" == "dn") continue; if ("$val" == "objectclass") continue; - $lastkey[$level]=$key; + $lastkey[$level] = $key; if (is_array($val)) { - $hide=0; - if (! is_numeric($key)) + $hide = 0; + if (!is_numeric($key)) { print ''; print ''; print $key; print ''; - if (strtolower($key) == 'userpassword') $hide=1; + if (strtolower($key) == 'userpassword') $hide = 1; } - show_ldap_content($val, $level+1, $count, $var, $hide, $val["count"]); + show_ldap_content($val, $level + 1, $count, $var, $hide, $val["count"]); } elseif ($subcount) { $subcount--; - $newstring=dol_htmlentitiesbr($val); + $newstring = dol_htmlentitiesbr($val); if ($hide) print preg_replace('/./i', '*', $newstring); else print $newstring; print '
    '; diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index d95acc75718..5ff4c77ae2e 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -85,45 +85,45 @@ */ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100, $multicurrency_tx = 1, $pu_devise = 0, $multicurrency_code = '') { - global $conf,$mysoc,$db; + global $conf, $mysoc, $db; - $result=array(); + $result = array(); // Clean parameters - if (empty($info_bits)) $info_bits=0; - if (empty($txtva)) $txtva=0; - if (empty($seller) || ! is_object($seller)) + if (empty($info_bits)) $info_bits = 0; + if (empty($txtva)) $txtva = 0; + if (empty($seller) || !is_object($seller)) { dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING); - if (! is_object($mysoc)) // mysoc may be not defined (during migration process) + if (!is_object($mysoc)) // mysoc may be not defined (during migration process) { - $mysoc=new Societe($db); + $mysoc = new Societe($db); $mysoc->setMysoc($conf); } - $seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc + $seller = $mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc //var_dump($seller->country_id);exit; } - if (empty($localtaxes_array) || ! is_array($localtaxes_array)) + if (empty($localtaxes_array) || !is_array($localtaxes_array)) { dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING); } // Too verbose. Enable for debug only //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); - $countryid=$seller->country_id; + $countryid = $seller->country_id; - if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; - if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate = (float) $uselocaltax1_rate; + if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate = (float) $uselocaltax2_rate; - if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; - if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; + if ($uselocaltax1_rate < 0) $uselocaltax1_rate = $seller->localtax1_assuj; + if ($uselocaltax2_rate < 0) $uselocaltax2_rate = $seller->localtax2_assuj; //var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate); dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress); // Now we search localtaxes information ourself (rates and types). - $localtax1_type=0; - $localtax2_type=0; + $localtax1_type = 0; + $localtax2_type = 0; if (is_array($localtaxes_array)) { @@ -137,19 +137,19 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING); $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; - $sql.= " WHERE cv.taux = ".$txtva; - $sql.= " AND cv.fk_pays = ".$countryid; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; + $sql .= " WHERE cv.taux = ".$txtva; + $sql .= " AND cv.fk_pays = ".$countryid; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { - $localtax1_rate=$obj->localtax1; - $localtax2_rate=$obj->localtax2; - $localtax1_type=$obj->localtax1_type; - $localtax2_type=$obj->localtax2_type; + $localtax1_rate = $obj->localtax1; + $localtax2_rate = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit; } } @@ -158,14 +158,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // pu calculation from pu_devise if pu empty if (empty($pu) && !empty($pu_devise)) { - if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; + if (!empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; else { dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); return array(); } } - if ($pu === '') $pu=0; + if ($pu === '') $pu = 0; // pu_devise calculation from pu if (empty($pu_devise) && !empty($multicurrency_tx)) { if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; @@ -178,11 +178,11 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // initialize total (may be HT or TTC depending on price_base_type) $tot_sans_remise = $pu * $qty * $progress / 100; - $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); + $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); // initialize result array - for ($i=0; $i <= 15; $i++) $result[$i] = 0; + for ($i = 0; $i <= 15; $i++) $result[$i] = 0; // if there's some localtax including vat, we calculate localtaxes (we will add later) @@ -202,9 +202,9 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_wt."-".$pu_wt."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n"; - $localtaxes = array(0,0,0); + $localtaxes = array(0, 0, 0); $apply_tax = false; - switch($localtax1_type) { + switch ($localtax1_type) { case '2': // localtax on product or service $apply_tax = true; break; @@ -217,18 +217,18 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } if ($uselocaltax1_rate && $apply_tax) { - $result[14] = price2num(($tot_sans_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); + $result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); $localtaxes[0] += $result[14]; - $result[9] = price2num(($tot_avec_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); + $result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); $localtaxes[1] += $result[9]; - $result[11] = price2num(($pu_wt * (1 + ( $localtax1_rate / 100))) - $pu_wt, 'MU'); + $result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU'); $localtaxes[2] += $result[11]; } $apply_tax = false; - switch($localtax2_type) { + switch ($localtax2_type) { case '2': // localtax on product or service $apply_tax = true; break; @@ -240,13 +240,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt break; } if ($uselocaltax2_rate && $apply_tax) { - $result[15] = price2num(($tot_sans_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); + $result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); $localtaxes[0] += $result[15]; - $result[10] = price2num(($tot_avec_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); + $result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); $localtaxes[1] += $result[10]; - $result[12] = price2num(($pu_wt * (1 + ( $localtax2_rate / 100))) - $pu_wt, 'MU'); + $result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU'); $localtaxes[2] += $result[12]; } @@ -255,36 +255,36 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt { // We work to define prices using the price without tax $result[6] = price2num($tot_sans_remise, 'MT'); - $result[8] = price2num($tot_sans_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non - $result8bis= price2num($tot_sans_remise * (1 + ( $txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR) + $result[8] = price2num($tot_sans_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non + $result8bis = price2num($tot_sans_remise * (1 + ($txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR) $result[7] = price2num($result8bis - ($result[6] + $localtaxes[0]), 'MT'); $result[0] = price2num($tot_avec_remise, 'MT'); - $result[2] = price2num($tot_avec_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non - $result2bis= price2num($tot_avec_remise * (1 + ( $txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR) - $result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) + $result[2] = price2num($tot_avec_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non + $result2bis = price2num($tot_avec_remise * (1 + ($txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR) + $result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) $result[3] = price2num($pu, 'MU'); - $result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non - $result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR) + $result[5] = price2num($pu * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non + $result5bis = price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR) $result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU'); } else { // We work to define prices using the price with tax $result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT'); - $result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non - $result6bis= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) + $result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MT'); // Selon TVA NPR ou non + $result6bis = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) $result[7] = price2num($result[8] - ($result6bis + $localtaxes[0]), 'MT'); $result[2] = price2num($tot_avec_remise + $localtaxes[1], 'MT'); - $result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non - $result0bis= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) - $result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) + $result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MT'); // Selon TVA NPR ou non + $result0bis = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) + $result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) $result[5] = price2num($pu + $localtaxes[2], 'MU'); - $result[3] = price2num($pu / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non - $result3bis= price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR) + $result[3] = price2num($pu / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MU'); // Selon TVA NPR ou non + $result3bis = price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR) $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU'); } @@ -293,13 +293,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation if ($price_base_type == 'TTC') { - $tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU'); - $tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU'); + $tot_sans_remise = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU'); + $tot_avec_remise = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU'); $pu = price2num($pu / (1 + ($txtva / 100)), 'MU'); } $apply_tax = false; - switch($localtax1_type) { + switch ($localtax1_type) { case '1': // localtax on product or service $apply_tax = true; break; @@ -311,18 +311,18 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt break; } if ($uselocaltax1_rate && $apply_tax) { - $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount - $result[8] += $result[14]; // total_ttc_without_discount + tax1 + $result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount + $result[8] += $result[14]; // total_ttc_without_discount + tax1 - $result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht - $result[2] += $result[9]; // total_ttc + tax1 + $result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht + $result[2] += $result[9]; // total_ttc + tax1 - $result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht - $result[5] += $result[11]; // pu_ht + tax1 + $result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht + $result[5] += $result[11]; // pu_ht + tax1 } $apply_tax = false; - switch($localtax2_type) { + switch ($localtax2_type) { case '1': // localtax on product or service $apply_tax = true; break; @@ -334,34 +334,34 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt break; } if ($uselocaltax2_rate && $apply_tax) { - $result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount - $result[8] += $result[15]; // total_ttc_without_discount + tax2 + $result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount + $result[8] += $result[15]; // total_ttc_without_discount + tax2 - $result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht - $result[2] += $result[10]; // total_ttc + tax2 + $result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht + $result[2] += $result[10]; // total_ttc + tax2 - $result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht - $result[5] += $result[12]; // pu_ht + tax2 + $result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht + $result[5] += $result[12]; // pu_ht + tax2 } // If rounding is not using base 10 (rare) - if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT)) + if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT)) { if ($price_base_type == 'HT') { - $result[0]=round($result[0]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[2]=price2num($result[0]+$result[1], 'MT'); - $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; + $result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[2] = price2num($result[0] + $result[1], 'MT'); + $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; } else { - $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[0]=price2num($result[2]-$result[1], 'MT'); - $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; - $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; + $result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[0] = price2num($result[2] - $result[1], 'MT'); + $result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; + $result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT; } } @@ -377,7 +377,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $keyforforeignMAIN_MAX_DECIMALS_UNIT = 'MAIN_MAX_DECIMALS_UNIT_'.$multicurrency_code; $keyforforeignMAIN_MAX_DECIMALS_TOT = 'MAIN_MAX_DECIMALS_TOT_'.$multicurrency_code; $keyforforeignMAIN_ROUNDING_RULE_TOT = 'MAIN_ROUNDING_RULE_TOT_'.$multicurrency_code; - if (! empty($conf->global->$keyforforeignMAIN_ROUNDING_RULE_TOT)) { + if (!empty($conf->global->$keyforforeignMAIN_ROUNDING_RULE_TOT)) { $conf->global->MAIN_MAX_DECIMALS_UNIT = $keyforforeignMAIN_MAX_DECIMALS_UNIT; $conf->global->MAIN_MAX_DECIMALS_TOT = $keyforforeignMAIN_MAX_DECIMALS_TOT; $conf->global->MAIN_ROUNDING_RULE_TOT = $keyforforeignMAIN_ROUNDING_RULE_TOT; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 18ef68550a4..a16140f91cf 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -69,37 +69,37 @@ class doc_generic_shipment_odt extends ModelePdfExpedition global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva EXPEDITION_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva EXPEDITION_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -111,82 +111,82 @@ class doc_generic_shipment_odt extends ModelePdfExpedition */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.=''; } - $texte.= '
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -206,7 +206,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -215,17 +215,17 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -233,11 +233,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if ($conf->expedition->dir_output."/sending") { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Expedition($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -247,14 +247,14 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $dir = $conf->expedition->dir_output."/sending"; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -262,25 +262,25 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$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)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -290,19 +290,19 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // If SHIPMENT contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name $contactobject = null; - if (! empty($usecontact)) { + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; @@ -314,7 +314,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -323,15 +323,15 @@ class doc_generic_shipment_odt extends ModelePdfExpedition ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='EXPEDITION_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'EXPEDITION_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -341,15 +341,15 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $srctemplatepath, array( 'PATH_TO_TMP' => $conf->expedition->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -364,15 +364,15 @@ class doc_generic_shipment_odt extends ModelePdfExpedition try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Make substitutions into odt of user info - $tmparray=$this->get_substitutionarray_user($user, $outputlangs); + $tmparray = $this->get_substitutionarray_user($user, $outputlangs); //var_dump($tmparray); exit; - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -392,9 +392,9 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } } // Make substitutions into odt of mysoc - $tmparray=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); //var_dump($tmparray); exit; - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -419,7 +419,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } else { $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); } - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -439,8 +439,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } if ($usecontact && is_object($contactobject)) { - $tmparray=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); - foreach($tmparray as $key=>$value) + $tmparray = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -453,7 +453,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -461,12 +461,12 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } // Replace tags of object + external modules - $tmparray=$this->get_substitutionarray_shipment($object, $outputlangs); + $tmparray = $this->get_substitutionarray_shipment($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $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) + $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) { try { if (preg_match('/logo$/', $key)) // Image @@ -479,7 +479,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -491,7 +491,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition 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; @@ -501,22 +501,22 @@ class doc_generic_shipment_odt extends ModelePdfExpedition { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_shipment_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_shipment_lines($line, $outputlangs); 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) + $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) { 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); } @@ -528,14 +528,14 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -547,15 +547,15 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -564,26 +564,26 @@ class doc_generic_shipment_odt extends ModelePdfExpedition try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $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 + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index be264918a89..d19eb584d81 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -68,37 +68,37 @@ class doc_generic_invoice_odt extends ModelePDFFactures global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT/ODS templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'FACTURE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'FACTURE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -113,79 +113,79 @@ class doc_generic_invoice_odt extends ModelePDFFactures global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->FACTURE_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->FACTURE_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->FACTURE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->FACTURE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.=''; } - $texte.= '
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -205,7 +205,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -214,17 +214,17 @@ class doc_generic_invoice_odt extends ModelePDFFactures } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -232,11 +232,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures if ($conf->facture->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Facture($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -246,14 +246,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures $dir = $conf->facture->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -261,26 +261,26 @@ class doc_generic_invoice_odt extends ModelePDFFactures if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; //print "newdir=".$dir; //print "newfile=".$newfile; @@ -291,19 +291,19 @@ class doc_generic_invoice_odt extends ModelePDFFactures // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name $contactobject = null; - if (! empty($usecontact)) { + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; @@ -321,7 +321,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $propal_object = $object->linkedObjects['propal'][0]; // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -330,15 +330,15 @@ class doc_generic_invoice_odt extends ModelePDFFactures ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='INVOICE_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'INVOICE_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -348,7 +348,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $srctemplatepath, array( 'PATH_TO_TMP' => $conf->facture->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) @@ -356,7 +356,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -378,26 +378,26 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object, $outputlangs, 'propal'):array(); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array(); + $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_propal, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $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 + $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 //var_dump($tmparray); exit; - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -423,7 +423,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures 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; @@ -433,22 +433,22 @@ class doc_generic_invoice_odt extends ModelePDFFactures { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); 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) + $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) { 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); } @@ -458,36 +458,36 @@ class doc_generic_invoice_odt extends ModelePDFFactures $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + 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); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -496,26 +496,26 @@ class doc_generic_invoice_odt extends ModelePDFFactures try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $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 + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 63e647e113c..1a225518518 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -80,7 +80,7 @@ class printing_printgcp extends PrintingDriver // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $this->db = $db; @@ -103,10 +103,10 @@ class printing_printgcp extends PrintingDriver $this->google_secret, $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' ); - $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); + $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? 'HasAccessToken' : 'NoAccessToken'); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); - $token_ok=true; + $token_ok = true; try { $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); } catch (Exception $e) { @@ -140,10 +140,10 @@ class printing_printgcp extends PrintingDriver 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), - 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'') + 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp') : '') ); if ($token_ok) { - $expiredat=''; + $expiredat = ''; $refreshtoken = $token->getRefreshToken(); @@ -159,11 +159,11 @@ class printing_printgcp extends PrintingDriver } else { - $expiredat=dol_print_date($endoflife, "dayhour"); + $expiredat = dol_print_date($endoflife, "dayhour"); } - $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); - $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); + $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((!empty($refreshtoken)) ? 'Yes' : 'No'), 'type'=>'info'); + $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire ? 'Yes' : 'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info'); } /* @@ -193,37 +193,37 @@ class printing_printgcp extends PrintingDriver $langs->load('printing'); $html = ''; - $html.= ''.$langs->trans('GCP_Name').''; - $html.= ''.$langs->trans('GCP_displayName').''; - $html.= ''.$langs->trans('GCP_Id').''; - $html.= ''.$langs->trans('GCP_OwnerName').''; - $html.= ''.$langs->trans('GCP_State').''; - $html.= ''.$langs->trans('GCP_connectionStatus').''; - $html.= ''.$langs->trans('GCP_Type').''; - $html.= ''.$langs->trans("Select").''; - $html.= ''."\n"; + $html .= ''.$langs->trans('GCP_Name').''; + $html .= ''.$langs->trans('GCP_displayName').''; + $html .= ''.$langs->trans('GCP_Id').''; + $html .= ''.$langs->trans('GCP_OwnerName').''; + $html .= ''.$langs->trans('GCP_State').''; + $html .= ''.$langs->trans('GCP_connectionStatus').''; + $html .= ''.$langs->trans('GCP_Type').''; + $html .= ''.$langs->trans("Select").''; + $html .= ''."\n"; $list = $this->getlistAvailablePrinters(); //$html.= '
    '.print_r($list,true).'
    '; foreach ($list['available'] as $printer_det) { - $html.= ''; - $html.= ''.$printer_det['name'].''; - $html.= ''.$printer_det['displayName'].''; - $html.= ''.$printer_det['id'].''; // id to identify printer to use - $html.= ''.$printer_det['ownerName'].''; - $html.= ''.$printer_det['status'].''; - $html.= ''.$langs->trans('STATE_'.$printer_det['connectionStatus']).''; - $html.= ''.$langs->trans('TYPE_'.$printer_det['type']).''; + $html .= ''; + $html .= ''.$printer_det['name'].''; + $html .= ''.$printer_det['displayName'].''; + $html .= ''.$printer_det['id'].''; // id to identify printer to use + $html .= ''.$printer_det['ownerName'].''; + $html .= ''.$printer_det['status'].''; + $html .= ''.$langs->trans('STATE_'.$printer_det['connectionStatus']).''; + $html .= ''.$langs->trans('TYPE_'.$printer_det['type']).''; // Defaut - $html.= ''; + $html .= ''; if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id']) { - $html.= img_picto($langs->trans("Default"), 'on'); + $html .= img_picto($langs->trans("Default"), 'on'); } else - $html.= ''.img_picto($langs->trans("Disabled"), 'off').''; - $html.= ''; - $html.= ''."\n"; + $html .= ''.img_picto($langs->trans("Disabled"), 'off').''; + $html .= ''; + $html .= ''."\n"; } $this->resprint = $html; return $error; @@ -249,7 +249,7 @@ class printing_printgcp extends PrintingDriver $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); // Check if we have auth token - $token_ok=true; + $token_ok = true; try { $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); } catch (Exception $e) { @@ -285,12 +285,12 @@ class printing_printgcp extends PrintingDriver $responsedata = json_decode($response, true); $printers = $responsedata['printers']; // Check if we have printers? - if(count($printers)==0) { + if (count($printers) == 0) { // We dont have printers so return blank array - $ret['available'] = array(); + $ret['available'] = array(); } else { // We have printers so returns printers as array - $ret['available'] = $printers; + $ret['available'] = $printers; } return $ret; } @@ -311,10 +311,10 @@ class printing_printgcp extends PrintingDriver $error = 0; $fileprint = $conf->{$module}->dir_output; - if ($subdir!='') { - $fileprint.='/'.$subdir; + if ($subdir != '') { + $fileprint .= '/'.$subdir; } - $fileprint.='/'.$file; + $fileprint .= '/'.$file; $mimetype = dol_mimetype($fileprint); // select printer uri for module order, propal,... $sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$module."' AND driver='printgcp' AND userid=".$user->id; @@ -328,9 +328,9 @@ class printing_printgcp extends PrintingDriver } else { - if (! empty($conf->global->PRINTING_GCP_DEFAULT)) + if (!empty($conf->global->PRINTING_GCP_DEFAULT)) { - $printer_id=$conf->global->PRINTING_GCP_DEFAULT; + $printer_id = $conf->global->PRINTING_GCP_DEFAULT; } else { @@ -345,7 +345,7 @@ class printing_printgcp extends PrintingDriver $ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype); $this->error = 'PRINTGCP: '.$ret['errormessage']; - if ($ret['status']!=1) { + if ($ret['status'] != 1) { $error++; } return $error; @@ -364,12 +364,12 @@ class printing_printgcp extends PrintingDriver { // Check if printer id if (empty($printerid)) { - return array('status' =>0, 'errorcode' =>'','errormessage'=>'No provided printer ID'); + return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'No provided printer ID'); } // Open the file which needs to be print $handle = fopen($filepath, "rb"); - if(!$handle) { - return array('status' =>0, 'errorcode' =>'','errormessage'=>'Could not read the file.'); + if (!$handle) { + return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'Could not read the file.'); } // Read file content $contents = fread($handle, filesize($filepath)); @@ -394,7 +394,7 @@ class printing_printgcp extends PrintingDriver $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); // Check if we have auth token and refresh it - $token_ok=true; + $token_ok = true; try { $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); } catch (Exception $e) { @@ -442,7 +442,7 @@ class printing_printgcp extends PrintingDriver $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); // Check if we have auth token - $token_ok=true; + $token_ok = true; try { $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); } catch (Exception $e) { diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index b8cc6ac3b4c..5a3d2481c6d 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -41,14 +41,14 @@ class printing_printipp extends PrintingDriver public $conf = array(); public $host; public $port; - public $userid; /* user login */ + public $userid; /* user login */ public $user; public $password; /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -70,11 +70,11 @@ class printing_printipp extends PrintingDriver { global $conf; - $this->db=$db; - $this->host=$conf->global->PRINTIPP_HOST; - $this->port=$conf->global->PRINTIPP_PORT; - $this->user=$conf->global->PRINTIPP_USER; - $this->password=$conf->global->PRINTIPP_PASSWORD; + $this->db = $db; + $this->host = $conf->global->PRINTIPP_HOST; + $this->port = $conf->global->PRINTIPP_PORT; + $this->user = $conf->global->PRINTIPP_USER; + $this->password = $conf->global->PRINTIPP_PASSWORD; $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); @@ -104,7 +104,7 @@ class printing_printipp extends PrintingDriver $ipp->setPort($this->port); $ipp->setJobName($file, true); $ipp->setUserName($this->userid); - if (! empty($this->user)) $ipp->setAuthentication($this->user, $this->password); + if (!empty($this->user)) $ipp->setAuthentication($this->user, $this->password); // select printer uri for module order, propal,... $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; @@ -118,7 +118,7 @@ class printing_printipp extends PrintingDriver } else { - if (! empty($conf->global->PRINTIPP_URI_DEFAULT)) + if (!empty($conf->global->PRINTIPP_URI_DEFAULT)) { dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT); $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); @@ -136,9 +136,9 @@ class printing_printipp extends PrintingDriver // Set number of copy $ipp->setCopies($obj->copy); - $fileprint=$conf->{$module}->dir_output; - if ($subdir!='') $fileprint.='/'.$subdir; - $fileprint.='/'.$file; + $fileprint = $conf->{$module}->dir_output; + if ($subdir != '') $fileprint .= '/'.$subdir; + $fileprint .= '/'.$file; $ipp->setData($fileprint); try { $ipp->printJob(); @@ -146,7 +146,7 @@ class printing_printipp extends PrintingDriver $this->errors[] = $e->getMessage(); $error++; } - if ($error==0) $this->errors[] = 'PRINTIPP: Job added'; + if ($error == 0) $this->errors[] = 'PRINTIPP: Job added'; return $error; } @@ -162,42 +162,42 @@ class printing_printipp extends PrintingDriver $error = 0; $html = ''; - $html.= ''.$langs->trans('IPP_Uri').''; - $html.= ''.$langs->trans('IPP_Name').''; - $html.= ''.$langs->trans('IPP_State').''; - $html.= ''.$langs->trans('IPP_State_reason').''; - $html.= ''.$langs->trans('IPP_State_reason1').''; - $html.= ''.$langs->trans('IPP_BW').''; - $html.= ''.$langs->trans('IPP_Color').''; + $html .= ''.$langs->trans('IPP_Uri').''; + $html .= ''.$langs->trans('IPP_Name').''; + $html .= ''.$langs->trans('IPP_State').''; + $html .= ''.$langs->trans('IPP_State_reason').''; + $html .= ''.$langs->trans('IPP_State_reason1').''; + $html .= ''.$langs->trans('IPP_BW').''; + $html .= ''.$langs->trans('IPP_Color').''; //$html.= ''.$langs->trans('IPP_Device').''; - $html.= ''.$langs->trans('IPP_Media').''; - $html.= ''.$langs->trans('IPP_Supported').''; - $html.= ''.$langs->trans("Select").''; - $html.= "\n"; + $html .= ''.$langs->trans('IPP_Media').''; + $html .= ''.$langs->trans('IPP_Supported').''; + $html .= ''.$langs->trans("Select").''; + $html .= "\n"; $list = $this->getlistAvailablePrinters(); foreach ($list as $value) { $printer_det = $this->getPrinterDetail($value); - $html.= ''; - $html.= ''.$value.''; + $html .= ''; + $html .= ''.$value.''; //$html.= '
    '.print_r($printer_det,true).'
    '; - $html.= ''.$printer_det->printer_name->_value0.''; - $html.= ''.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).''; - $html.= ''.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).''; - $html.= ''.(! empty($printer_det->printer_state_reasons->_value1)?$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1):'').''; - $html.= ''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).''; - $html.= ''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).''; + $html .= ''.$printer_det->printer_name->_value0.''; + $html .= ''.$langs->trans('STATE_IPP_'.$printer_det->printer_state->_value0).''; + $html .= ''.$langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value0).''; + $html .= ''.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans('STATE_IPP_'.$printer_det->printer_state_reasons->_value1) : '').''; + $html .= ''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value2).''; + $html .= ''.$langs->trans('IPP_COLOR_'.$printer_det->printer_type->_value3).''; //$html.= ''.$printer_det->device_uri->_value0.''; - $html.= ''.$printer_det->media_default->_value0.''; - $html.= ''.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).''; + $html .= ''.$printer_det->media_default->_value0.''; + $html .= ''.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).''; // Defaut - $html.= ''; + $html .= ''; if ($conf->global->PRINTIPP_URI_DEFAULT == $value) { - $html.= img_picto($langs->trans("Default"), 'on'); + $html .= img_picto($langs->trans("Default"), 'on'); } else { - $html.= ''.img_picto($langs->trans("Disabled"), 'off').''; + $html .= ''.img_picto($langs->trans("Disabled"), 'off').''; } - $html.= ''; - $html.= ''."\n"; + $html .= ''; + $html .= ''."\n"; } $this->resprint = $html; return $error; @@ -217,7 +217,7 @@ class printing_printipp extends PrintingDriver $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); - if (! empty($this->user)) { + if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } $ipp->getPrinters(); @@ -232,7 +232,7 @@ class printing_printipp extends PrintingDriver */ private function getPrinterDetail($uri) { - global $conf,$db; + global $conf, $db; include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; $ipp = new CupsPrintIPP(); @@ -240,7 +240,7 @@ class printing_printipp extends PrintingDriver $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); - if (! empty($this->user)) { + if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } $ipp->setPrinterURI($uri); @@ -266,7 +266,7 @@ class printing_printipp extends PrintingDriver $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); - if (! empty($this->user)) { + if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } // select printer uri for module order, propal,... diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index e57d4dc2733..bdb9d8485d6 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -39,7 +39,7 @@ class doc_generic_reception_odt extends ModelePdfReception /** * @var Company Issuer object that emits */ - public $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet /** * @var array Minimum version of PHP required by module. @@ -60,7 +60,7 @@ class doc_generic_reception_odt extends ModelePdfReception */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $langs->load("main"); $langs->load("companies"); @@ -68,32 +68,32 @@ class doc_generic_reception_odt extends ModelePdfReception $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'RECEPTION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva RECEPTION_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -105,7 +105,7 @@ class doc_generic_reception_odt extends ModelePdfReception */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; $langs->load("companies"); $langs->load("errors"); @@ -113,74 +113,74 @@ class doc_generic_reception_odt extends ModelePdfReception $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.=''; } - $texte.= '
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -200,7 +200,7 @@ class doc_generic_reception_odt extends ModelePdfReception public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -209,17 +209,17 @@ class doc_generic_reception_odt extends ModelePdfReception } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -229,11 +229,11 @@ class doc_generic_reception_odt extends ModelePdfReception if ($conf->reception->dir_output."/reception") { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Reception($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -243,14 +243,14 @@ class doc_generic_reception_odt extends ModelePdfReception $dir = $conf->reception->dir_output."/reception"; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -258,25 +258,25 @@ class doc_generic_reception_odt extends ModelePdfReception if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$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)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -286,28 +286,28 @@ class doc_generic_reception_odt extends ModelePdfReception // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - if (! empty($usecontact)) + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else $socobject = $object->thirdparty; } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -316,15 +316,15 @@ class doc_generic_reception_odt extends ModelePdfReception ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='RECEPTION_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'RECEPTION_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -334,15 +334,15 @@ class doc_generic_reception_odt extends ModelePdfReception $srctemplatepath, array( 'PATH_TO_TMP' => $conf->reception->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } // After construction $odfHandler->contentXml contains content and @@ -355,14 +355,14 @@ class doc_generic_reception_odt extends ModelePdfReception // 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); } // Make substitutions into odt of user info - $tmparray=$this->get_substitutionarray_user($user, $outputlangs); + $tmparray = $this->get_substitutionarray_user($user, $outputlangs); //var_dump($tmparray); exit; - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -375,14 +375,14 @@ class doc_generic_reception_odt extends ModelePdfReception { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch(OdfException $e) { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Make substitutions into odt of mysoc - $tmparray=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); //var_dump($tmparray); exit; - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -395,13 +395,13 @@ class doc_generic_reception_odt extends ModelePdfReception { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch(OdfException $e) { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Make substitutions into odt of thirdparty - $tmparray=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - foreach($tmparray as $key=>$value) + $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -413,17 +413,17 @@ class doc_generic_reception_odt extends ModelePdfReception { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch(OdfException $e) { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Replace tags of object + external modules - $tmparray=$this->get_substitutionarray_reception($object, $outputlangs); + $tmparray = $this->get_substitutionarray_reception($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $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) + $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) { try { if (preg_match('/logo$/', $key)) // Image @@ -435,7 +435,7 @@ class doc_generic_reception_odt extends ModelePdfReception { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch(OdfException $e) { + } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } @@ -445,18 +445,18 @@ class doc_generic_reception_odt extends ModelePdfReception $listlines = $odfHandler->setSegment('lines'); foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_reception_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs); 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) + $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) { 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); } } @@ -464,58 +464,58 @@ class doc_generic_reception_odt extends ModelePdfReception } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + 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); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); return -1; } } else { try { $odfHandler->saveToDisk($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); return -1; } } - $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 + $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 + $odfHandler = null; // Destroy object - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 4d8692822d7..f38798ab958 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -66,37 +66,37 @@ class doc_generic_stock_odt extends ModelePDFStock global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'STOCK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'STOCK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva STOCK_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva STOCK_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -111,60 +111,60 @@ class doc_generic_stock_odt extends ModelePDFStock global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->STOCK_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->STOCK_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; /*if ($conf->global->MAIN_STOCK_CHOOSE_ODT_DOCUMENT > 0) { @@ -192,15 +192,15 @@ class doc_generic_stock_odt extends ModelePDFStock }*/ } - $texte.= '
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -220,7 +220,7 @@ class doc_generic_stock_odt extends ModelePDFStock public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $stock,$langs,$conf,$mysoc,$hookmanager,$user; + global $stock, $langs, $conf, $mysoc, $hookmanager, $user; if (empty($srctemplatepath)) { @@ -229,17 +229,17 @@ class doc_generic_stock_odt extends ModelePDFStock } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -247,11 +247,11 @@ class doc_generic_stock_odt extends ModelePDFStock if ($conf->product->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Stock($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -264,14 +264,14 @@ class doc_generic_stock_odt extends ModelePDFStock $dir = $conf->product->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -279,26 +279,26 @@ class doc_generic_stock_odt extends ModelePDFStock if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -308,20 +308,20 @@ class doc_generic_stock_odt extends ModelePDFStock // If CUSTOMER contact defined on stock, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; @@ -331,10 +331,10 @@ class doc_generic_stock_odt extends ModelePDFStock } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -343,15 +343,15 @@ class doc_generic_stock_odt extends ModelePDFStock ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='stock_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'stock_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -361,15 +361,15 @@ class doc_generic_stock_odt extends ModelePDFStock $srctemplatepath, array( 'PATH_TO_TMP' => $conf->product->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -394,22 +394,22 @@ class doc_generic_stock_odt extends ModelePDFStock $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in stock 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_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('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 + $parameters = array('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 @@ -431,25 +431,25 @@ class doc_generic_stock_odt extends ModelePDFStock try { $listlines = $odfHandler->setSegment('supplierprices'); - if(!empty($object->supplierprices)){ + if (!empty($object->supplierprices)) { foreach ($object->supplierprices as $supplierprice) { $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($array_lines as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($array_lines 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); } @@ -459,36 +459,36 @@ class doc_generic_stock_odt extends ModelePDFStock } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + 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); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -497,26 +497,26 @@ class doc_generic_stock_odt extends ModelePDFStock try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php index cfaf1334b5b..db473766a43 100644 --- a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php @@ -69,37 +69,37 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'SUPPLIER_ORDER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'SUPPLIER_ORDER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere issuer - $this->issuer=$mysoc; - if (! $this->issuer->country_code) $this->issuer->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->issuer = $mysoc; + if (!$this->issuer->country_code) $this->issuer->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -111,83 +111,83 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_ORDER_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_ORDER_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.=''; } - $texte.= '
    '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
    '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
    '; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -207,7 +207,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -216,17 +216,17 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -237,22 +237,22 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders if ($object->specimen) { $dir = $conf->fournisseur->commande->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); - $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; - $file = $dir . "/" . $objectref . ".pdf"; - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; + $dir = $conf->fournisseur->commande->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -260,25 +260,25 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$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)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -288,20 +288,20 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -310,11 +310,11 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->issuer->name, '__FROM_EMAIL__' => $this->issuer->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -323,15 +323,15 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='ORDER_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'ORDER_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -341,15 +341,15 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $srctemplatepath, array( 'PATH_TO_TMP' => $conf->fournisseur->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -364,31 +364,31 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $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); // Call the ODTSubstitution hook - $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 + $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 @@ -401,7 +401,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -413,7 +413,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders 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; @@ -423,22 +423,22 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); 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) + $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) { 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); } @@ -448,21 +448,21 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + 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); } @@ -470,15 +470,15 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -487,27 +487,27 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $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 + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index dcc9457e588..3bb92cb9cf7 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -67,37 +67,37 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -117,106 +117,106 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= '"; + $texte .= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.=''; if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) { // Model for creation - $liste=ModelePDFSupplierProposal::liste_modeles($this->db); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '"; + $liste = ModelePDFSupplierProposal::liste_modeles($this->db); + $texte .= '
    '.$langs->trans("DefaultModelSupplierProposalCreate").''; - $texte.= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT); - $texte.= "
    '; + $texte .= ''; + $texte .= ''; + $texte .= '"; - $texte.= ''; - $texte.= ''; - $texte.= '"; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= '"; + $texte .= ''; - $texte.= ''; - $texte.= '"; - $texte.= '
    '.$langs->trans("DefaultModelSupplierProposalCreate").''; + $texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT); + $texte .= "
    '.$langs->trans("DefaultModelSupplierProposalToBill").''; - $texte.= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL); - $texte.= "
    '.$langs->trans("DefaultModelSupplierProposalToBill").''; + $texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL); + $texte .= "
    '.$langs->trans("DefaultModelSupplierProposalClosed").''; - $texte.= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED); - $texte.= "
    '; + $texte .= '
    '.$langs->trans("DefaultModelSupplierProposalClosed").''; + $texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED); + $texte .= "
    '; } } - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; + $texte .= ''; - $texte.= ''; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -245,17 +245,17 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "companies", "bills", "dict")); @@ -263,11 +263,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal if ($conf->supplier_proposal->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new SupplierProposal($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -277,14 +277,14 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $dir = $conf->supplier_proposal->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -292,26 +292,26 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -321,28 +321,28 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // If BILLING contact defined on invoice, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'BILLING'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'BILLING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - if (! empty($usecontact)) + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else $socobject = $object->thirdparty; } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -351,15 +351,15 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -369,7 +369,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $srctemplatepath, array( 'PATH_TO_TMP' => $conf->supplier_proposal->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) @@ -377,7 +377,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -399,20 +399,20 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $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 + $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 @@ -425,7 +425,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -437,7 +437,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal 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; @@ -447,22 +447,22 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); 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) + $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) { 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); } @@ -472,36 +472,36 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + 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); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -510,26 +510,26 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $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 + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index ebd40b806a5..7177cec3f07 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -64,37 +64,37 @@ class doc_generic_user_odt extends ModelePDFUser global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'USER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'USER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva USER_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva USER_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -114,91 +114,91 @@ class doc_generic_user_odt extends ModelePDFUser $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= '"; + $texte .= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USER_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USER_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { // Model for creation - $liste=ModelePDFUser::liste_modeles($this->db); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '"; + $liste = ModelePDFUser::liste_modeles($this->db); + $texte .= '
    '.$langs->trans("DefaultModelPropalCreate").''; - $texte.= $form->selectarray('value2', $liste, $conf->global->USER_ADDON_PDF_ODT_DEFAULT); - $texte.= "
    '; + $texte .= ''; + $texte .= ''; + $texte .= '"; - $texte.= ''; - $texte.= ''; - $texte.= '"; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= '"; + $texte .= ''; - $texte.= ''; - $texte.= '"; - $texte.= '
    '.$langs->trans("DefaultModelPropalCreate").''; + $texte .= $form->selectarray('value2', $liste, $conf->global->USER_ADDON_PDF_ODT_DEFAULT); + $texte .= "
    '.$langs->trans("DefaultModelPropalToBill").''; - $texte.= $form->selectarray('value3', $liste, $conf->global->USER_ADDON_PDF_ODT_TOBILL); - $texte.= "
    '.$langs->trans("DefaultModelPropalToBill").''; + $texte .= $form->selectarray('value3', $liste, $conf->global->USER_ADDON_PDF_ODT_TOBILL); + $texte .= "
    '.$langs->trans("DefaultModelPropalClosed").''; - $texte.= $form->selectarray('value4', $liste, $conf->global->USER_ADDON_PDF_ODT_CLOSED); - $texte.= "
    '; + $texte .= '
    '.$langs->trans("DefaultModelPropalClosed").''; + $texte .= $form->selectarray('value4', $liste, $conf->global->USER_ADDON_PDF_ODT_CLOSED); + $texte .= "
    '; } } - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; + $texte .= ''; - $texte.= ''; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -227,17 +227,17 @@ class doc_generic_user_odt extends ModelePDFUser } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "companies", "bills", "dict")); @@ -245,11 +245,11 @@ class doc_generic_user_odt extends ModelePDFUser if ($conf->user->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new User($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -259,14 +259,14 @@ class doc_generic_user_odt extends ModelePDFUser $dir = $conf->user->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -274,26 +274,26 @@ class doc_generic_user_odt extends ModelePDFUser if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -303,19 +303,19 @@ class doc_generic_user_odt extends ModelePDFUser // If CUSTOMER contact defined on user, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - if (! empty($usecontact)) + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -324,7 +324,7 @@ class doc_generic_user_odt extends ModelePDFUser } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Open and load template @@ -334,35 +334,35 @@ class doc_generic_user_odt extends ModelePDFUser $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } // Make substitutions into odt - $array_user=$this->get_substitutionarray_user($object, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($object, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $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($array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); $object->fetch_optionals(); // Call the ODTSubstitution hook - $parameters=array('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) + $parameters = array('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) { try { if (preg_match('/logo$/', $key)) // Image @@ -375,15 +375,15 @@ class doc_generic_user_odt extends ModelePDFUser $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_WARNING); } } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -395,15 +395,15 @@ class doc_generic_user_odt extends ModelePDFUser } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } @@ -412,26 +412,26 @@ class doc_generic_user_odt extends ModelePDFUser try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -452,7 +452,7 @@ class doc_generic_user_odt extends ModelePDFUser { // phpcs:enable $array_other = array(); - foreach($object as $key => $value) { + foreach ($object as $key => $value) { if (!is_array($value) && !is_object($value)) { $array_other[$array_key.'_'.$key] = $value; } diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 2dbe87bdccf..dfc187e636a 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -67,37 +67,37 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'USERGROUP_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva USERGROUP_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva USERGROUP_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -109,99 +109,99 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
    \n"; - $texte.= '
    '; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
    '; // List of directories area - $texte.= ''; + $texte .= '"; + $texte .= '
    '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
    '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $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); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; - $texte.= ''; - $texte.= '
    '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; + $texte .= ''; + $texte .= '
    '; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { // Model for creation - $liste=ModelePDFUserGroup::liste_modeles($this->db); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '"; + $liste = ModelePDFUserGroup::liste_modeles($this->db); + $texte .= '
    '.$langs->trans("DefaultModelPropalCreate").''; - $texte.= $form->selectarray('value2', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT); - $texte.= "
    '; + $texte .= ''; + $texte .= ''; + $texte .= '"; - $texte.= ''; - $texte.= ''; - $texte.= '"; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= '"; + $texte .= ''; - $texte.= ''; - $texte.= '"; - $texte.= '
    '.$langs->trans("DefaultModelPropalCreate").''; + $texte .= $form->selectarray('value2', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT); + $texte .= "
    '.$langs->trans("DefaultModelPropalToBill").''; - $texte.= $form->selectarray('value3', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL); - $texte.= "
    '.$langs->trans("DefaultModelPropalToBill").''; + $texte .= $form->selectarray('value3', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL); + $texte .= "
    '.$langs->trans("DefaultModelPropalClosed").''; - $texte.= $form->selectarray('value4', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED); - $texte.= "
    '; + $texte .= '
    '.$langs->trans("DefaultModelPropalClosed").''; + $texte .= $form->selectarray('value4', $liste, $conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED); + $texte .= "
    '; } } - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; + $texte .= ''; - $texte.= ''; - $texte.= '
    '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -230,17 +230,17 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } // 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 = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "companies", "bills", "dict")); @@ -248,11 +248,11 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup if ($conf->user->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new UserGroup($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -262,14 +262,14 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $dir = $conf->usergroup->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -277,26 +277,26 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + 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'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -306,19 +306,19 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // If CUSTOMER contact defined on user, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - if (! empty($usecontact)) + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -327,10 +327,10 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -339,15 +339,15 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='user_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'user_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -357,13 +357,13 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } @@ -384,23 +384,23 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } // Make substitutions into odt - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_global=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_objet=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_global = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_objet = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $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($array_global, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); $object->fetch_optionals(); // Call the ODTSubstitution hook - $parameters=array('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) + $parameters = array('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) { try { @@ -436,14 +436,14 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup { foreach ($object->members as $u) { - $tmparray=$this->get_substitutionarray_each_var_object($u, $outputlangs); + $tmparray = $this->get_substitutionarray_each_var_object($u, $outputlangs); unset($tmparray['object_pass']); unset($tmparray['object_pass_indatabase']); complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$u); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$u); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { @@ -465,16 +465,16 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key => $value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key => $value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -486,15 +486,15 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } @@ -503,26 +503,26 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_WARNING); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $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 + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 2c1b5085e89..12bb5053a46 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -64,21 +64,21 @@ $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; -$coldisplay=0; ?> +$coldisplay = 0; ?> > -global->MAIN_VIEW_LINE_NUMBER)) { ?> - +global->MAIN_VIEW_LINE_NUMBER)) { ?> +
    info_bits & 2) == 2) { print ''; - $txt=''; + $txt = ''; print img_object($langs->trans("ShowReduc"), 'reduc').' '; - if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); - elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid"); + if ($line->description == '(DEPOSIT)') $txt = $langs->trans("Deposit"); + elseif ($line->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived"); + elseif ($line->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; print ''; @@ -86,55 +86,55 @@ if (($line->info_bits & 2) == 2) { { if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) { - $discount=new DiscountAbsolute($this->db); + $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { - $discount=new DiscountAbsolute($this->db); + $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($this->db); + $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { - $discount=new DiscountAbsolute($this->db); + $discount = new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); } else { - echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); + echo ($txt ? ' - ' : '').dol_htmlentitiesbr($line->description); } } } else { - $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day'; + $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE ? 'dayhour' : 'day'; if ($line->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { - if ($type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + if (!empty($line->label)) { + $text .= ' '.$line->label.''; + echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { - if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); + if (!empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); echo $text.' '.dol_htmlentitiesbr($line->description); } } @@ -153,9 +153,9 @@ else } // Add description in form - if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if ($line->fk_product > 0 && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($line->description) && $line->description!=$line->product_label)?'
    '.dol_htmlentitiesbr($line->description):''; + print (!empty($line->description) && $line->description != $line->product_label) ? '
    '.dol_htmlentitiesbr($line->description) : ''; } } @@ -164,7 +164,7 @@ if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productfourn = new ProductFournisseur($this->db); $productfourn->fetch_product_fournisseur_price($line->fk_fournprice); - echo '
    ' . $langs->trans('Supplier') . ' : ' . $productfourn->getSocNomUrl(1, 'supplier') . ' - ' . $langs->trans('Ref') . ' : '; + echo '
    '.$langs->trans('Supplier').' : '.$productfourn->getSocNomUrl(1, 'supplier').' - '.$langs->trans('Ref').' : '; // Supplier ref if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here { @@ -176,29 +176,29 @@ if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0) } } -if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) +if (!empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { - $accountingaccount=new AccountingAccount($this->db); + $accountingaccount = new AccountingAccount($this->db); $accountingaccount->fetch($line->fk_accounting_account); - echo '

    ' . $langs->trans('AccountingAffectation') . ' : ' . $accountingaccount->getNomUrl(0, 1, 1); + echo '

    '.$langs->trans('AccountingAffectation').' : '.$accountingaccount->getNomUrl(0, 1, 1); } print ''; if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { print ''; - echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier); + echo ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; } // VAT Rate print ''; $coldisplay++; -$positiverates=''; -if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); -if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); -if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); -if (empty($positiverates)) $positiverates='0'; -echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits); +$positiverates = ''; +if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); +if (price2num($line->total_localtax1)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); +if (price2num($line->total_localtax2)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); +if (empty($positiverates)) $positiverates = '0'; +echo vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); ?> @@ -209,7 +209,7 @@ echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':'' - pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?> + pu_ttc) ?price($line->pu_ttc) : price($line->subprice)); ?> @@ -219,7 +219,7 @@ if ((($line->info_bits & 2) != 2) && $line->special_code != 3) { // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price + echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price } else echo ' '; print ''; @@ -248,26 +248,26 @@ if ($this->situation_cycle_ref) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; - print '' . $line->situation_percent . '%'; + print ''.$line->situation_percent.'%'; $coldisplay++; - $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier?$mysoc:$object->thirdparty), ($senderissupplier?$object->thirdparty:$mysoc)); - $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier?$object->thirdparty:$mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); - print '' . price($tmp[0]) . ''; + $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc)); + $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); + print ''.price($tmp[0]).''; } -if ($usemargins && ! empty($conf->margin->enabled) && empty($user->socid)) +if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid)) { if (!empty($user->rights->margins->creer)) { ?> pa_ht); ?> global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> - pa_ht == 0)?'n/a':price(price2num($line->marge_tx, 'MT')).'%'); ?> + if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> + pa_ht == 0) ? 'n/a' : price(price2num($line->marge_tx, 'MT')).'%'); ?> global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> + if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> marque_tx, 'MT')).'%'; ?> special_code == 3) { ?> +if ($line->special_code == 3) { ?> trans('Option'); ?> '; @@ -276,9 +276,9 @@ if ($line->special_code == 3) { ?> { print 'country_code).'='.price($line->total_ht); - print '
    '.$langs->transcountry("TotalVAT", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_tva); - if (price2num($line->total_localtax1)) print '
    '.$langs->transcountry("TotalLT1", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax1); - if (price2num($line->total_localtax2)) print '
    '.$langs->transcountry("TotalLT2", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax2); + print '
    '.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); + if (price2num($line->total_localtax1)) print '
    '.$langs->transcountry("TotalLT1", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_localtax1); + if (price2num($line->total_localtax2)) print '
    '.$langs->transcountry("TotalLT2", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_localtax2); print '
    '.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); print '">'; } @@ -298,10 +298,10 @@ if ($outputalsopricetotalwithtax) { $coldisplay++; } -if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) { +if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines') { print ''; $coldisplay++; - if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { + if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { ?> id.'#line_'.$line->id; ?>"> '; @@ -310,8 +310,8 @@ if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) print ''; $coldisplay++; - if (($line->fk_prev_id == null ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation - print 'id . '">'; + if (($line->fk_prev_id == null) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation + print 'id.'">'; print img_delete(); print ''; } @@ -325,23 +325,23 @@ if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) + if ($i < $num - 1) { ?> id; ?>"> '; } else { - print 'browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'>'; + print 'browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; $coldisplay++; } } else { print ''; - $coldisplay = $coldisplay+3; + $coldisplay = $coldisplay + 3; } if ($action == 'selectlines') { ?> - + \n"; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 265268f6e6f..ab12b48aa08 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -17,7 +17,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; @@ -29,32 +29,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); -if (GETPOST('dol_hide_topmenu')) $conf->dol_hide_topmenu=1; -if (GETPOST('dol_hide_leftmenu')) $conf->dol_hide_leftmenu=1; -if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen=1; -if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover=1; -if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; +if (GETPOST('dol_hide_topmenu')) $conf->dol_hide_topmenu = 1; +if (GETPOST('dol_hide_leftmenu')) $conf->dol_hide_leftmenu = 1; +if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen = 1; +if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover = 1; +if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile = 1; // If we force to use jmobile, then we reenable javascript -if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; +if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1; $php_self = $_SERVER['PHP_SELF']; -$php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''; +$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; -$titleofpage=$langs->trans('SendNewPassword'); +$titleofpage = $langs->trans('SendNewPassword'); print top_htmlhead('', $titleofpage); -$colorbackhmenu1='60,70,100'; // topmenu -if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1=$colorbackhmenu1; -$colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1) :(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); -$colorbackhmenu1=join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' +$colorbackhmenu1 = '60,70,100'; // topmenu +if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; +$colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1); +$colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' ?> -global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode('logos/'.$conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> +global->MAIN_LOGIN_BACKGROUND) ? '' : ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode('logos/'.$conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> dol_use_jmobile)) { ?> '; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 44b3f4cab4e..393d5416d52 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -180,12 +180,12 @@ class Mo extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array(); + protected $childtables = array(); /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array('mrp_production'); + protected $childtablesoncascade = array('mrp_production'); /** * @var MoLine[] Array of subtable lines @@ -251,14 +251,14 @@ class Mo extends CommonObject } // Insert lines in mrp_production table - if (! $error && $this->fk_bom > 0) + if (!$error && $this->fk_bom > 0) { include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; $bom = new Bom($this->db); $bom->fetch($this->fk_bom); if ($bom->id > 0) { - foreach($bom->lines as $line) + foreach ($bom->lines as $line) { $moline = new MoLine($this->db); @@ -289,7 +289,7 @@ class Mo extends CommonObject } } - if (! $error) { + if (!$error) { $this->db->commit(); } else { $this->db->rollback(); @@ -818,9 +818,9 @@ class Mo extends CommonObject //print ''.$form->showCheckAddButtons('checkforselect', 1).''; print ''; print ''; - $i = 0; + $i = 0; - if (! empty($this->lines)) + if (!empty($this->lines)) { foreach ($this->lines as $line) { @@ -828,9 +828,9 @@ class Mo extends CommonObject { if (empty($line->fk_parent_line)) { - $parameters=array('line'=>$line, 'i'=>$i); - $action=''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('line'=>$line, 'i'=>$i); + $action = ''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } else @@ -863,12 +863,12 @@ class Mo extends CommonObject $this->tpl['id'] = $line->id; - $this->tpl['label']=''; - if (! empty($line->fk_product)) + $this->tpl['label'] = ''; + if (!empty($line->fk_product)) { $productstatic = new Product($this->db); $productstatic->fetch($line->fk_product); - $this->tpl['label'].= $productstatic->getNomUrl(1); + $this->tpl['label'] .= $productstatic->getNomUrl(1); //$this->tpl['label'].= ' - '.$productstatic->label; } else @@ -912,7 +912,7 @@ class MoLine extends CommonObjectLine */ public $isextrafieldmanaged = 0; - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'fk_mo' =>array('type'=>'integer', 'label'=>'Fk mo', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), @@ -976,13 +976,13 @@ class MoLine extends CommonObjectLine // Translate some data of arrayofkeyval if (is_object($langs)) { - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 05a86f3e25b..df6abec3d22 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -24,10 +24,10 @@ * \brief Page des stats des commandes fournisseurs pour un produit */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('orders', 'products', 'companies')); @@ -36,22 +36,22 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (! empty($user->socid)) +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array ( +$hookmanager->initHooks(array( 'productstatssupplyorder' )); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -59,9 +59,9 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) +if (!$sortorder) $sortorder = "DESC"; -if (! $sortfield) +if (!$sortfield) $sortfield = "c.date_commande"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -82,23 +82,23 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters = array ('id' => $id); + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - llxHeader("", "", $langs->trans("CardProduct" . $product->type)); + llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { $head = product_prepare_head($product); - $titre = $langs->trans("CardProduct" . $product->type); + $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -133,26 +133,26 @@ if ($id > 0 || ! empty($ref)) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " c.rowid, d.total_ht as total_ht, c.ref,"; $sql .= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.rowid, d.qty"; - if (! $user->rights->societe->client->voir && ! $socid) + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c"; - $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseurdet as d"; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseurdet as d"; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity = " . $conf->entity; + $sql .= " AND c.entity = ".$conf->entity; $sql .= " AND d.fk_commande = c.rowid"; - $sql .= " AND d.fk_product =" . $product->id; - if (! empty($search_month)) - $sql .= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql .= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) - $sql .= " AND c.fk_soc = " . $socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " AND c.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; @@ -172,33 +172,33 @@ if ($id > 0 || ! empty($ref)) { if ($result) { $num = $db->num_rows($result); - if (! empty($id)) - $option .= '&id=' . $product->id; - if (! empty($search_month)) - $option .= '&search_month=' . $search_month; - if (! empty($search_year)) - $option .= '&search_year=' . $search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if (!empty($id)) + $option .= '&id='.$product->id; + if (!empty($search_month)) + $option .= '&search_month='.$search_month; + if (!empty($search_year)) + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '
    ' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; - print ''; - print ''; + print ''; + print ''; print '
    '; print '
    '; print '
    '; @@ -222,8 +222,8 @@ if ($id > 0 || ! empty($ref)) { { $objp = $db->fetch_object($result); - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; $supplierorderstatic->id = $objp->commandeid; $supplierorderstatic->ref = $objp->ref; @@ -234,13 +234,13 @@ if ($id > 0 || ! empty($ref)) { print ''; print $supplierorderstatic->getNomUrl(1); print "\n"; - print '' . $societestatic->getNomUrl(1) . ''; - print "" . $objp->code_client . "\n"; + print ''.$societestatic->getNomUrl(1).''; + print "".$objp->code_client."\n"; print ''; - print dol_print_date($db->jdate($objp->date_commande), 'dayhour') . ""; - print '' . $objp->qty . "\n"; - print '' . price($objp->total_ht) . "\n"; - print '' . $supplierorderstatic->getLibStatut(4) . ''; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour').""; + print ''.$objp->qty."\n"; + print ''.price($objp->total_ht)."\n"; + print ''.$supplierorderstatic->getLibStatut(4).''; print "\n"; $i++; } @@ -249,8 +249,8 @@ if ($id > 0 || ! empty($ref)) { if ($num < $limit) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; print ''; - print '' . $total_qty . ''; - print '' . price($total_ht) . ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; print ''; print ""; print '

    '; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 7c21fb60a15..a478a542f0f 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -35,10 +35,10 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatscontract')); @@ -46,7 +46,7 @@ $hookmanager->initHooks(array('productstatscontract')); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -54,47 +54,47 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="c.date_contrat"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "c.date_contrat"; /* * View */ -$staticcontrat=new Contrat($db); -$staticcontratligne=new ContratLigne($db); +$staticcontrat = new Contrat($db); +$staticcontratligne = new ContratLigne($db); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters=array('id'=>$id); - $reshook=$hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($product); + $titre = $langs->trans("CardProduct".$product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -113,31 +113,31 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); - $now=dol_now(); + $now = dol_now(); $sql = "SELECT"; - $sql.= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; - $sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,"; - $sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", 1, 0).') as nb_late,'; - $sql.= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; - $sql.= " c.rowid as rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut as statut,"; - $sql.= " s.nom as name, s.rowid as socid, s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE c.rowid = cd.fk_contrat"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; - $sql.= " AND cd.fk_product =".$product->id; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; - $sql.= $db->order($sortfield, $sortorder); + $sql .= ' sum('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; + $sql .= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > '".$db->idate($now)."'", 1, 0).") as nb_running,"; + $sql .= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= '".$db->idate($now)."')", 1, 0).') as nb_late,'; + $sql .= ' sum('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; + $sql .= " c.rowid as rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut as statut,"; + $sql .= " s.nom as name, s.rowid as socid, s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE c.rowid = cd.fk_contrat"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " AND cd.fk_product =".$product->id; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; + $sql .= $db->order($sortfield, $sortorder); //Calcul total qty and amount for global if full scan list - $total_ht=0; - $total_qty=0; + $total_ht = 0; + $total_qty = 0; // Count total nb of records $totalofrecords = ''; @@ -153,22 +153,22 @@ if ($id > 0 || ! empty($ref)) if ($result) { $num = $db->num_rows($result); - if (! empty($id)) - $option .= '&id=' . $product->id; - if (! empty($search_month)) - $option .= '&search_month=' . $search_month; - if (! empty($search_year)) - $option .= '&search_year=' . $search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if (!empty($id)) + $option .= '&id='.$product->id; + if (!empty($search_month)) + $option .= '&search_month='.$search_month; + if (!empty($search_year)) + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); @@ -188,7 +188,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($staticcontratligne->LibStatut(5, 3), $_SERVER["PHP_SELF"], "", '', '', 'align="center" width="16"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $contracttmp=new Contrat($db); + $contracttmp = new Contrat($db); if ($num > 0) { @@ -211,9 +211,9 @@ if ($id > 0 || ! empty($ref)) print dol_print_date($db->jdate($objp->date_contrat), 'dayhour').""; //print "".price($objp->total_ht)."\n"; //print ''; - print ''.($objp->nb_initial>0?$objp->nb_initial:'').''; - print ''.($objp->nb_running+$objp->nb_late>0?$objp->nb_running+$objp->nb_late:'').''; - print ''.($objp->nb_closed>0?$objp->nb_closed:'').''; + print ''.($objp->nb_initial > 0 ? $objp->nb_initial : '').''; + print ''.($objp->nb_running + $objp->nb_late > 0 ? $objp->nb_running + $objp->nb_late : '').''; + print ''.($objp->nb_closed > 0 ? $objp->nb_closed : '').''; //$contratstatic->LibStatut($objp->statut,5).''; print "\n"; $i++; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index c1caa90a8d3..34247393106 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -26,10 +26,10 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'products', 'companies')); @@ -38,10 +38,10 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; -if (! empty($user->socid)) $socid=$user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -50,7 +50,7 @@ $hookmanager->initHooks(array('productstatssupplyinvoice')); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -58,8 +58,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $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"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -78,7 +78,7 @@ $societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); @@ -89,12 +89,12 @@ if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - llxHeader("", "", $langs->trans("CardProduct" . $product->type)); + llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { $head = product_prepare_head($product); - $titre = $langs->trans("CardProduct" . $product->type); + $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -128,22 +128,22 @@ if ($id > 0 || ! empty($ref)) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; - if (! $user->rights->societe->client->voir && ! $socid) + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn_det as d"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn_det as d"; + 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.entity IN (".getEntity('facture_fourn').")"; $sql .= " AND d.fk_facture_fourn = f.rowid"; - $sql .= " AND d.fk_product =" . $product->id; - if (! empty($search_month)) - $sql .= ' AND MONTH(f.datef) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql .= ' AND YEAR(f.datef) IN (' . $search_year . ')'; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; - if ($socid) $sql .= " AND f.fk_soc = " . $socid; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; $sql .= " ORDER BY $sortfield $sortorder "; // Calcul total qty and amount for global if full scan list @@ -158,40 +158,40 @@ if ($id > 0 || ! empty($ref)) $totalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - if (! empty($id)) - $option .= '&id=' . $product->id; - if (! empty($search_month)) - $option .= '&search_month=' . $search_month; - if (! empty($search_year)) - $option .= '&search_year=' . $search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if (!empty($id)) + $option .= '&id='.$product->id; + if (!empty($search_month)) + $option .= '&search_month='.$search_month; + if (!empty($search_year)) + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; - print ''; - print ''; + print ''; + print ''; print '
    '; print '
    '; print '
    '; @@ -215,8 +215,8 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->line_total_ht; - $total_qty+=$objp->qty; + $total_ht += $objp->line_total_ht; + $total_qty += $objp->qty; $supplierinvoicestatic->id = $objp->facid; $supplierinvoicestatic->ref = $objp->ref; @@ -233,13 +233,13 @@ if ($id > 0 || ! empty($ref)) print ''; print $supplierinvoicestatic->getNomUrl(1); print "\n"; - print '' . $societestatic->getNomUrl(1) . ''; - print "" . $objp->code_client . "\n"; + print ''.$societestatic->getNomUrl(1).''; + print "".$objp->code_client."\n"; print ''; - print dol_print_date($db->jdate($objp->datef), 'dayhour') . ""; - print '' . $objp->qty . "\n"; - print '' . price($objp->line_total_ht) . "\n"; - print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''; + print dol_print_date($db->jdate($objp->datef), 'dayhour').""; + print ''.$objp->qty."\n"; + print ''.price($objp->line_total_ht)."\n"; + print ''.$supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; } @@ -248,8 +248,8 @@ if ($id > 0 || ! empty($ref)) if ($num < $limit) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; print ''; - print '' . $total_qty . ''; - print '' . price($total_ht) . ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; print ''; print ""; print '
    '; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index f8893dce3e1..17e9c37158c 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -25,10 +25,10 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'companies')); @@ -37,19 +37,19 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array ('productstatspropal')); +$hookmanager->initHooks(array('productstatspropal')); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -57,8 +57,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder = "DESC"; -if (! $sortfield) $sortfield = "p.datep"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.datep"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -73,28 +73,28 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', */ $propalstatic = new Propal($db); -$societestatic=new Societe($db); +$societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters = array ('id' => $id); + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - llxHeader("", "", $langs->trans("CardProduct" . $product->type)); + llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { $head = product_prepare_head($product); - $titre = $langs->trans("CardProduct" . $product->type); + $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -129,26 +129,26 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; $sql .= " p.ref_client,"; $sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty"; - if (! $user->rights->societe->client->voir && ! $socid) + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= "," . MAIN_DB_PREFIX . "propal as p"; - $sql .= ", " . MAIN_DB_PREFIX . "propaldet as d"; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ",".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."propaldet as d"; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND d.fk_propal = p.rowid"; - $sql .= " AND d.fk_product =" . $product->id; - if (! empty($search_month)) - $sql .= ' AND MONTH(p.datep) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql .= ' AND YEAR(p.datep) IN (' . $search_year . ')'; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) - $sql .= " AND p.fk_soc = " . $socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " AND p.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; @@ -169,33 +169,33 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($result); - if (! empty($id)) - $option .= '&id=' . $product->id; - if (! empty($search_month)) - $option .= '&search_month=' . $search_month; - if (! empty($search_year)) - $option .= '&search_year=' . $search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if (!empty($id)) + $option .= '&id='.$product->id; + if (!empty($search_month)) + $option .= '&search_month='.$search_month; + if (!empty($search_year)) + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; - print ''; - print ''; + print ''; + print ''; print '
    '; print '
    '; print '
    '; @@ -218,12 +218,12 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->amount; - $total_qty+=$objp->qty; + $total_ht += $objp->amount; + $total_qty += $objp->qty; - $propalstatic->id=$objp->propalid; - $propalstatic->ref=$objp->ref; - $propalstatic->ref_client=$objp->ref_client; + $propalstatic->id = $objp->propalid; + $propalstatic->ref = $objp->ref; + $propalstatic->ref_client = $objp->ref_client; $societestatic->fetch($objp->socid); print ''; @@ -232,10 +232,10 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; - print dol_print_date($db->jdate($objp->datep), 'dayhour') . ""; - print "" . $objp->qty . "\n"; - print '' . price($objp->amount) . '' . "\n"; - print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; + print dol_print_date($db->jdate($objp->datep), 'dayhour').""; + print "".$objp->qty."\n"; + print ''.price($objp->amount).''."\n"; + print ''.$propalstatic->LibStatut($objp->statut, 5).''; print "\n"; $i++; } @@ -245,8 +245,8 @@ if ($id > 0 || ! empty($ref)) if ($num < $limit) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; print ''; - print '' . $total_qty . ''; - print '' . price($total_ht) . ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; print ''; print ""; print ''; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 9c76cca7c96..c344170e674 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -25,10 +25,10 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'companies')); @@ -37,19 +37,19 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array ('productstatspropal')); +$hookmanager->initHooks(array('productstatspropal')); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -57,8 +57,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder = "DESC"; -if (! $sortfield) $sortfield = "p.date_valid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.date_valid"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -73,28 +73,28 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', */ $propalstatic = new SupplierProposal($db); -$societestatic=new Societe($db); +$societestatic = new Societe($db); $form = new Form($db); $formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters = array ('id' => $id); + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - llxHeader("", "", $langs->trans("CardProduct" . $product->type)); + llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { $head = product_prepare_head($product); - $titre = $langs->trans("CardProduct" . $product->type); + $titre = $langs->trans("CardProduct".$product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); @@ -105,7 +105,7 @@ if ($id > 0 || ! empty($ref)) $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -129,26 +129,26 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; //$sql .= " p.ref_supplier,"; $sql .= "p.date_valid, p.fk_statut as statut, d.rowid, d.qty"; - if (! $user->rights->societe->client->voir && ! $socid) + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= "," . MAIN_DB_PREFIX . "supplier_proposal as p"; - $sql .= ", " . MAIN_DB_PREFIX . "supplier_proposaldet as d"; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ",".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."supplier_proposaldet as d"; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql .= " AND d.fk_supplier_proposal = p.rowid"; - $sql .= " AND d.fk_product =" . $product->id; - if (! empty($search_month)) - $sql .= ' AND MONTH(p.datep) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql .= ' AND YEAR(p.datep) IN (' . $search_year . ')'; - if (! $user->rights->societe->client->voir && ! $socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) - $sql .= " AND p.fk_soc = " . $socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " AND p.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; @@ -169,33 +169,33 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($result); - if (! empty($id)) - $option .= '&id=' . $product->id; - if (! empty($search_month)) - $option .= '&search_month=' . $search_month; - if (! empty($search_year)) - $option .= '&search_year=' . $search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if (!empty($id)) + $option .= '&id='.$product->id; + if (!empty($search_month)) + $option .= '&search_month='.$search_month; + if (!empty($search_year)) + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("DatePropal").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; - print ''; - print ''; + print ''; + print ''; print '
    '; print '
    '; print '
    '; @@ -218,11 +218,11 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->amount; - $total_qty+=$objp->qty; + $total_ht += $objp->amount; + $total_qty += $objp->qty; - $propalstatic->id=$objp->propalid; - $propalstatic->ref=$objp->ref; + $propalstatic->id = $objp->propalid; + $propalstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); print ''; @@ -231,10 +231,10 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; - print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . ""; - print "" . $objp->qty . "\n"; - print '' . price($objp->amount) . '' . "\n"; - print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; + print dol_print_date($db->jdate($objp->date_valid), 'dayhour').""; + print "".$objp->qty."\n"; + print ''.price($objp->amount).''."\n"; + print ''.$propalstatic->LibStatut($objp->statut, 5).''; print "\n"; $i++; } @@ -244,8 +244,8 @@ if ($id > 0 || ! empty($ref)) if ($num < $limit) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; print ''; - print '' . $total_qty . ''; - print '' . price($total_ht) . ''; + print ''.$total_qty.''; + print ''.price($total_ht).''; print ''; print ""; print ''; diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 35e40cf786c..ab011dd219a 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -22,8 +22,8 @@ * \brief Page to list surveys */ -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -32,17 +32,17 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; // Init vars -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $numsondage = ''; if (GETPOST('sondage')) { $numsondage = GETPOST('sondage', 'alpha'); } -$object=new Opensurveysondage($db); -$result=$object->fetch(0, $numsondage); +$object = new Opensurveysondage($db); +$result = $object->fetch(0, $numsondage); -$nblines=$object->fetch_lines(); +$nblines = $object->fetch_lines(); //If the survey has not yet finished, then it can be modified $canbemodified = ((empty($object->date_fin) || $object->date_fin > dol_now()) && $object->status != Opensurveysondage::STATUS_CLOSED); @@ -57,40 +57,40 @@ if (empty($conf->opensurvey->enabled)) accessforbidden('', 0, 0, 1); $nbcolonnes = substr_count($object->sujet, ',') + 1; -$listofvoters=explode(',', $_SESSION["savevoter"]); +$listofvoters = explode(',', $_SESSION["savevoter"]); // Add comment if (GETPOST('ajoutcomment', 'alpha')) { if (!$canbemodified) accessforbidden('', 0, 0, 1); - $error=0; + $error = 0; $comment = GETPOST("comment", 'none'); $comment_user = GETPOST('commentuser', 'nohtml'); - if (! $comment) + if (!$comment) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } - if (! $comment_user) + if (!$comment_user) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } - if (! in_array($comment_user, $listofvoters)) + if (!in_array($comment_user, $listofvoters)) { setEventMessages($langs->trans("UserMustBeSameThanUserUsedToVote"), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $resql = $object->addComment($comment, $comment_user); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } @@ -103,29 +103,29 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout if (GETPOST('nom', 'nohtml')) { $nouveauchoix = ''; - for ($i=0;$i<$nbcolonnes;$i++) + for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $nom=substr(GETPOST("nom", 'nohtml'), 0, 64); + $nom = substr(GETPOST("nom", 'nohtml'), 0, 64); // Check if vote already exists $sql = 'SELECT id_users, nom as name'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; + $sql .= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); $num_rows = $db->num_rows($resql); if ($num_rows > 0) @@ -136,14 +136,14 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout 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); + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; + $resql = $db->query($sql); if ($resql) { // Add voter to session - $_SESSION["savevoter"]=$nom.','.(empty($_SESSION["savevoter"])?'':$_SESSION["savevoter"]); // Save voter - $listofvoters=explode(',', $_SESSION["savevoter"]); + $_SESSION["savevoter"] = $nom.','.(empty($_SESSION["savevoter"]) ? '' : $_SESSION["savevoter"]); // Save voter + $listofvoters = explode(',', $_SESSION["savevoter"]); if ($object->mailsonde) { @@ -165,8 +165,8 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $body = str_replace('\n', '
    ', $langs->transnoentities('EmailSomeoneVoted', $nom, getUrlSondage($numsondage, true))); //var_dump($body);exit; - $cmailfile=new CMailFile("[".$application."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, null, null, null, '', '', 0, -1); - $result=$cmailfile->sendfile(); + $cmailfile = new CMailFile("[".$application."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, null, null, null, '', '', 0, -1); + $result = $cmailfile->sendfile(); } } } @@ -184,19 +184,19 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i=0; $i < $nblines; $i++) +for ($i = 0; $i < $nblines; $i++) { if (isset($_POST['modifierligne'.$i])) { - $ligneamodifier=$i; - $testligneamodifier=true; + $ligneamodifier = $i; + $testligneamodifier = true; } //test to see if a line is to be modified if (isset($_POST['validermodifier'.$i])) { - $modifier=$i; - $testmodifier=true; + $modifier = $i; + $testmodifier = true; } } @@ -204,35 +204,35 @@ if ($testmodifier) { //var_dump($_POST);exit; $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') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix".$i]) && $_POST["choix".$i] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } if (!$canbemodified) accessforbidden('', 0, 0, 1); - $idtomodify=$_POST["idtomodify".$modifier]; + $idtomodify = $_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'"; - $sql.= " WHERE id_users = '".$db->escape($idtomodify)."'"; + $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; + $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } // Delete comment -$idcomment=GETPOST('deletecomment', 'int'); +$idcomment = GETPOST('deletecomment', 'int'); if ($idcomment) { if (!$canbemodified) accessforbidden('', 0, 0, 1); @@ -246,10 +246,10 @@ if ($idcomment) * View */ -$form=new Form($db); +$form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss); if (empty($object->ref)) // For survey, id is a hex string @@ -264,14 +264,14 @@ if (empty($object->ref)) // For survey, id is a hex string } // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print '
    '.$langs->trans("YouAreInivitedToVote").'
    '; @@ -280,7 +280,7 @@ print $langs->trans("OpenSurveyHowTo").'

    '; print '
    '."\n"; //affichage du titre du sondage -$titre=str_replace("\\", "", $object->titre); +$titre = str_replace("\\", "", $object->titre); print ''.dol_htmlentities($titre).'

    '."\n"; //affichage des commentaires du sondage @@ -302,7 +302,7 @@ if (!$canbemodified) { } print ''."\n"; -print ''; +print ''; print '
    '."\n"; print '

    '."\n"; @@ -311,22 +311,22 @@ print '

    '."\n"; print ''."\n"; // Show choice titles -if ($object->format=="D") +if ($object->format == "D") { //display of survey topics print ''."\n"; print ''."\n"; //display of years - $colspan=1; - $nbofsujet=count($toutsujet); - for ($i=0;$i<$nbofsujet;$i++) + $colspan = 1; + $nbofsujet = count($toutsujet); + for ($i = 0; $i < $nbofsujet; $i++) { - if (isset($toutsujet[$i+1]) && date('Y', intval($toutsujet[$i])) == date('Y', intval($toutsujet[$i+1]))) { + if (isset($toutsujet[$i + 1]) && date('Y', intval($toutsujet[$i])) == date('Y', intval($toutsujet[$i + 1]))) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -335,21 +335,21 @@ if ($object->format=="D") print ''."\n"; //display of months - $colspan=1; - for ($i=0;$i<$nbofsujet;$i++) { - $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() + $colspan = 1; + for ($i = 0; $i < $nbofsujet; $i++) { + $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){ + if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -358,19 +358,19 @@ if ($object->format=="D") print ''."\n"; //display of days - $colspan=1; - for ($i=0;$i<$nbofsujet;$i++) { + $colspan = 1; + for ($i = 0; $i < $nbofsujet; $i++) { $cur = intval($toutsujet[$i]); - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -381,8 +381,8 @@ if ($object->format=="D") print ''."\n"; print ''."\n"; - for ($i=0; isset($toutsujet[$i]); $i++) { - $heures=explode('@', $toutsujet[$i]); + for ($i = 0; isset($toutsujet[$i]); $i++) { + $heures = explode('@', $toutsujet[$i]); if (isset($heures[1])) { print ''."\n"; } else { @@ -399,9 +399,9 @@ else print ''."\n"; print ''."\n"; - for ($i=0; isset($toutsujet[$i]); $i++) + for ($i = 0; isset($toutsujet[$i]); $i++) { - $tmp=explode('@', $toutsujet[$i]); + $tmp = explode('@', $toutsujet[$i]); print ''."\n"; } @@ -413,19 +413,19 @@ else $sumfor = array(); $sumagainst = array(); $compteur = 0; -$sql ="SELECT id_users, nom as name, id_sondage, reponses"; -$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; -$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; -$resql=$db->query($sql); -if (! $resql) +$sql = "SELECT id_users, nom as name, id_sondage, reponses"; +$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); exit; } -$num=$db->num_rows($resql); +$num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -443,40 +443,40 @@ while ($compteur < $num) print ''."\n"; // si la ligne n'est pas a changer, on affiche les données - if (! $testligneamodifier) + if (!$testligneamodifier) { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -491,20 +491,20 @@ while ($compteur < $num) { $car = substr($ensemblereponses, $i, 1); print ''."\n"; @@ -515,33 +515,33 @@ while ($compteur < $num) for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -556,7 +556,7 @@ while ($compteur < $num) } //demande de confirmation pour modification de ligne - for ($i=0; $i < $nblines; $i++) + for ($i = 0; $i < $nblines; $i++) { if (isset($_POST["modifierligne".$i])) { @@ -575,7 +575,7 @@ while ($compteur < $num) } // Add line to add new record -if ($ligneamodifier < 0 && (! isset($_SESSION['nom']))) +if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) { print ''."\n"; print ''."\n"; // affichage des cases de formulaire checkbox pour un nouveau choix - for ($i=0;$i<$nbcolonnes;$i++) + for ($i = 0; $i < $nbcolonnes; $i++) { print ''."\n"; @@ -619,10 +619,10 @@ if ($ligneamodifier < 0 && (! isset($_SESSION['nom']))) } // Select value of best choice (for checkbox columns only) -$nbofcheckbox=0; -for ($i=0; $i < $nbcolonnes; $i++) +$nbofcheckbox = 0; +for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) $nbofcheckbox++; if (isset($sumfor[$i])) { @@ -630,7 +630,7 @@ for ($i=0; $i < $nbcolonnes; $i++) { $meilleurecolonne = $sumfor[$i]; } - if (! isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne) + if (!isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne) { $meilleurecolonne = $sumfor[$i]; } @@ -640,18 +640,18 @@ for ($i=0; $i < $nbcolonnes; $i++) if ($object->allow_spy) { // Show line total print ''."\n"; - print ''."\n"; + print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - $showsumfor = isset($sumfor[$i])?$sumfor[$i]:''; - $showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:''; + $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; + $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; if (empty($showsumfor)) $showsumfor = 0; if (empty($showsumagainst)) $showsumagainst = 0; print ''."\n"; } print ''; @@ -660,10 +660,10 @@ if ($object->allow_spy) { { print ''."\n"; print ''."\n"; - for ($i=0; $i < $nbcolonnes; $i++) + for ($i = 0; $i < $nbcolonnes; $i++) { //print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print ''."\n"; } else { @@ -677,28 +677,28 @@ print '
    '.date('Y', intval($toutsujet[$i])).''.dol_print_date($cur, "%B").''.dol_print_date($cur, "%a %e").'
    '.dol_htmlentities($heures[1]).'
    '.$tmp[0].''.dol_htmlentities($obj->name).'OKKO'.$langs->trans("Yes").''.$langs->trans("No").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print 'OKKO'.$langs->trans("For").''.$langs->trans("Against").' '.$langs->trans("For").''.$langs->trans("Against").' 
    '."\n"; @@ -588,10 +588,10 @@ if ($ligneamodifier < 0 && (! isset($_SESSION['nom']))) print ''; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, GETPOST('choix'.$i)); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, GETPOST('choix'.$i)); } print '
    '. $langs->trans("Total") .''.$langs->trans("Total").''; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) print $showsumfor; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
    '.$langs->trans("No").': '.$showsumagainst; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
    '.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
    '.$langs->trans("No").': '.$showsumagainst; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
    '.$langs->trans("Against").': '.$showsumagainst; print '
    '."\n"; print '
    '."\n"; if ($object->allow_spy) { - $toutsujet=explode(",", $object->sujet); - $toutsujet=str_replace("°", "'", $toutsujet); + $toutsujet = explode(",", $object->sujet); + $toutsujet = str_replace("°", "'", $toutsujet); - $compteursujet=0; + $compteursujet = 0; $meilleursujet = ''; for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { - $meilleursujet.=", "; - if ($object->format=="D") { + $meilleursujet .= ", "; + if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); - $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext'). ' ('.dol_print_date($toutsujetdate[0], '%A').')' . ' - ' . $toutsujetdate[1]; + $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').' ('.dol_print_date($toutsujetdate[0], '%A').')'.' - '.$toutsujetdate[1]; } else { - $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext'). ' ('.dol_print_date($toutsujet[$i], '%A').')'; + $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').' ('.dol_print_date($toutsujet[$i], '%A').')'; } } else { - $tmps=explode('@', $toutsujet[$i]); + $tmps = explode('@', $toutsujet[$i]); $meilleursujet .= dol_htmlentities($tmps[0]); } @@ -706,7 +706,7 @@ if ($object->allow_spy) { } } - $meilleursujet=substr("$meilleursujet", 1); + $meilleursujet = substr("$meilleursujet", 1); $meilleursujet = str_replace("°", "'", $meilleursujet); @@ -717,9 +717,9 @@ if ($object->allow_spy) { print '

    '."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print ' ' . $langs->trans('TheBestChoice') . ": ".$meilleursujet." " . $langs->trans('with') . " $meilleurecolonne " . $vote_str . ".\n"; + print ' '.$langs->trans('TheBestChoice').": ".$meilleursujet." ".$langs->trans('with')." $meilleurecolonne ".$vote_str.".\n"; } elseif (isset($meilleurecolonne)) { - print ' ' . $langs->trans('TheBestChoices') . ": ".$meilleursujet." " . $langs->trans('with') . " $meilleurecolonne " . $vote_str . ".\n"; + print ' '.$langs->trans('TheBestChoices').": ".$meilleursujet." ".$langs->trans('with')." $meilleurecolonne ".$vote_str.".\n"; } print '


    '."\n"; @@ -734,7 +734,7 @@ $comments = $object->getComments(); if ($comments) { - print "
    " . $langs->trans("CommentsOfVoters") . ":
    \n"; + print "
    ".$langs->trans("CommentsOfVoters").":
    \n"; foreach ($comments as $obj) { // ligne d'un usager pré-authentifié @@ -749,15 +749,15 @@ if ($comments) // Form to add comment if ($object->allow_comments) { - print '
    ' .$langs->trans("AddACommentForPoll") . "
    \n"; + print '
    '.$langs->trans("AddACommentForPoll")."
    \n"; print '
    '."\n"; - print $langs->trans("Name") .': '; + print $langs->trans("Name").': '; print '   '."\n"; print '
    '."\n"; print ''."\n"; - print '
    '."\n"; // div add comment + print '
    '."\n"; // div add comment } print '

    '; diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 50f8a0e5d0d..0f87d01097d 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -26,17 +26,17 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","salaries","bills","hrm")); +$langs->loadLangs(array("compta", "salaries", "bills", "hrm")); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); $search_user = GETPOST('search_user', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -50,25 +50,25 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="s.datep,s.rowid"; -if (! $sortorder) $sortorder="DESC,DESC"; +if (!$sortfield) $sortfield = "s.datep,s.rowid"; +if (!$sortorder) $sortorder = "DESC,DESC"; $optioncss = GETPOST('optioncss', 'alpha'); -$filtre=$_GET["filtre"]; +$filtre = $_GET["filtre"]; if (empty($_REQUEST['typeid'])) { - $newfiltre=str_replace('filtre=', '', $filtre); - $filterarray=explode('-', $newfiltre); - foreach($filterarray as $val) + $newfiltre = str_replace('filtre=', '', $filtre); + $filterarray = explode('-', $newfiltre); + foreach ($filterarray as $val) { - $part=explode(':', $val); - if ($part[0] == 's.fk_typepayment') $typeid=$part[1]; + $part = explode(':', $val); + if ($part[0] == 's.fk_typepayment') $typeid = $part[1]; } } else { - $typeid=$_REQUEST['typeid']; + $typeid = $_REQUEST['typeid']; } @@ -79,11 +79,11 @@ else if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref=""; - $search_label=""; - $search_amount=""; - $search_account=''; - $typeid=""; + $search_ref = ""; + $search_label = ""; + $search_amount = ""; + $search_account = ''; + $typeid = ""; } @@ -99,56 +99,56 @@ $userstatic = new User($db); $accountstatic = new Account($db); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; -$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; -$sql.= " pst.code as payment_code"; -$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; -$sql.= " ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE u.rowid = s.fk_user"; -$sql.= " AND s.entity = ".$conf->entity; +$sql .= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; +$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; +$sql .= " pst.code as payment_code"; +$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; +$sql .= " ".MAIN_DB_PREFIX."user as u"; +$sql .= " WHERE u.rowid = s.fk_user"; +$sql .= " AND s.entity = ".$conf->entity; // Search criteria -if ($search_ref) $sql.=" AND s.rowid=".$search_ref; -if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); -if ($search_label) $sql.=natural_search(array('s.label'), $search_label); -if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); -if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; +if ($search_ref) $sql .= " AND s.rowid=".$search_ref; +if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); +if ($search_label) $sql .= natural_search(array('s.label'), $search_label); +if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); +if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; if ($filtre) { - $filtre=str_replace(":", "=", $filtre); + $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } if ($typeid) { $sql .= " AND s.fk_typepayment=".$typeid; } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); //$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code"; -$totalnboflines=0; -$result=$db->query($sql); +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($typeid) $param.='&typeid='.$typeid; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($typeid) $param .= '&typeid='.$typeid; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; - $newcardbutton=''; - if (! empty($user->rights->salaries->write)) + $newcardbutton = ''; + if (!empty($user->rights->salaries->write)) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/salaries/card.php?action=create'); } @@ -165,7 +165,7 @@ if ($result) print_barre_liste($langs->trans("SalariesPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print '
    '; - print ''."\n"; + print '
    '."\n"; print ''; // Ref @@ -185,7 +185,7 @@ if ($result) $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); print ''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; print ''; @@ -205,7 +205,7 @@ if ($result) print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -218,75 +218,75 @@ if ($result) print ''; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; - $userstatic->admin=$obj->admin; - $userstatic->login=$obj->login; - $userstatic->email=$obj->email; - $userstatic->socid=$obj->fk_soc; - $userstatic->statut=$obj->status; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->admin = $obj->admin; + $userstatic->login = $obj->login; + $userstatic->email = $obj->email; + $userstatic->socid = $obj->fk_soc; + $userstatic->statut = $obj->status; - $salstatic->id=$obj->rowid; - $salstatic->ref=$obj->rowid; + $salstatic->id = $obj->rowid; + $salstatic->ref = $obj->rowid; // Ref print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Employee print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Label payment print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Date payment print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Amount print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 8c73a914f40..6474495c86b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1097,7 +1097,7 @@ td.showDragHandle { #id-left { padding-top: 20px; padding-bottom: 5px; - global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN) && ! empty($conf->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) { ?> + global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN) && !empty($conf->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) { ?> padding-top: 8px; } @@ -1138,11 +1138,11 @@ div.blockvmenulogo border-bottom: 0 !important; } .menulogocontainer { - margin: px; + margin: px; margin-left: 11px; margin-right: 9px; padding: 0; - height: px; + height: px; /* width: 100px; */ max-width: 100px; vertical-align: middle; @@ -2070,8 +2070,8 @@ div.login_block_other { padding-top: 0; text-align: right; margin-right: 8px; } float: right; vertical-align: top; padding: 0px 3px 0px 4px !important; - line-height: px; - height: px; + line-height: px; + height: px; } .atoplogin, .atoplogin:hover { color: # !important; @@ -5976,4 +5976,4 @@ include dol_buildpath($path.'/theme/'.$theme.'/info-box.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/progress.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/timeline.inc.php', 0); -if (! empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; +if (!empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index bc00bd1c147..625b69e9228 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6079,6 +6079,6 @@ include dol_buildpath($path.'/theme/'.$theme.'/info-box.inc.php', 0); include dol_buildpath($path.'/theme/'.$theme.'/progress.inc.php', 0); include dol_buildpath($path.'/theme/eldy/timeline.inc.php', 0); // actually md use same style as eldy theme -if (! empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; +if (!empty($conf->global->THEME_CUSTOM_CSS)) print $conf->global->THEME_CUSTOM_CSS; if (is_object($db)) $db->close();
    '; $form->select_comptes($search_account, 'search_account', 0, '', 1); @@ -195,7 +195,7 @@ if ($result) print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
    ".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { - $accountstatic->account_number=$obj->account_number; + $accountstatic->account_number = $obj->account_number; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($obj->fk_accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - $accountstatic->label=$obj->blabel; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; print ''.price($obj->amount).'