diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 1afe2ecca18..f735a0a0cfc 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -332,7 +332,7 @@ if ($resql) else dol_print_error($db); print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; print '
'; print '
'; @@ -357,7 +357,7 @@ if ($resql) print ''; } if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print ' '; } + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print ' '; } if (!empty($arrayfields['aa.active']['checked'])) print ' '; print ''; $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); @@ -371,7 +371,7 @@ if ($resql) if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); } + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -453,11 +453,11 @@ if ($resql) if (!empty($arrayfields['aa.reconcilable']['checked'])) { print ''; if (empty($obj->reconcilable)) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 7449750f958..708165fc757 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -237,8 +237,8 @@ if ($action == 'create') { print ''; // Label short - print '' . $langs->trans("LabelToShow") . ''; - print ''; + print ''.$langs->trans("LabelToShow").''; + print ''; // Account parent print ''.$langs->trans("Accountparent").''; @@ -300,8 +300,8 @@ elseif ($id > 0 || $ref) { print ''; // Label short - print '' . $langs->trans("LabelToShow") . ''; - print ''; + print ''.$langs->trans("LabelToShow").''; + print ''; // Account parent print ''.$langs->trans("Accountparent").''; @@ -351,8 +351,8 @@ elseif ($id > 0 || $ref) { print ''.$object->label.''; // Label to show - print '' . $langs->trans("LabelToShow") . ''; - print '' . $object->labelshort . ''; + print ''.$langs->trans("LabelToShow").''; + print ''.$object->labelshort.''; // Account parent $accp = new AccountingAccount($db); diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index cc69462d893..63b2131f309 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -23,12 +23,12 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +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("compta","admin","accountancy")); +$langs->loadLangs(array("compta", "admin", "accountancy")); // Security check if (empty($user->rights->accounting->chartofaccount)) { @@ -38,7 +38,7 @@ if (empty($user->rights->accounting->chartofaccount)) { $action = GETPOST('action', 'aZ09'); -$list_account_main = array ( +$list_account_main = array( 'ACCOUNTING_RESULT_PROFIT', 'ACCOUNTING_RESULT_LOSS' ); @@ -52,23 +52,23 @@ if ($action == 'update') { $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); - if (! empty($defaultjournal)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!empty($defaultjournal)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -91,8 +91,8 @@ print load_fiche_titre($langs->trans('MenuClosureAccounts'), $linkback, 'title_a print ''.$langs->trans("DefaultClosureDesc").'
'; print '
'; -print '
'; -print ''; +print ''; +print ''; print ''; // Define main accounts for closure @@ -102,14 +102,14 @@ foreach ($list_account_main as $key) { print ''; // Param $label = $langs->trans($key); - $keydesc=$key.'_Desc'; + $keydesc = $key.'_Desc'; $htmltext = $langs->trans($keydesc); print ''; print $form->textwithpicto($label, $htmltext); print ''; // Value - print ''; // Do not force class=right, or it align also the content of the select box + print ''; // Do not force class=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print ''; print ''; @@ -117,15 +117,15 @@ foreach ($list_account_main as $key) { // Journal print ''; -print '' . $langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL") . ''; +print ''.$langs->trans("ACCOUNTING_CLOSURE_DEFAULT_JOURNAL").''; print ''; -$defaultjournal=$conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL; +$defaultjournal = $conf->global->ACCOUNTING_CLOSURE_DEFAULT_JOURNAL; print $formaccounting->select_journal($defaultjournal, "ACCOUNTING_CLOSURE_DEFAULT_JOURNAL", 9, 1, 0, 0); print ''; print "\n"; -print '
'; +print '
'; print '
'; diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index a02141f449e..f293c9b450b 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -22,23 +22,23 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","compta")); +$langs->loadLangs(array("admin", "compta")); // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear->write) +if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); $id = GETPOST('id', 'int'); // View -$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info"); +$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info"); $helpurl = ""; llxHeader("", $title, $helpurl); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index bb6f95d9047..78f29e97595 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -71,9 +71,9 @@ if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; - $sql.= $db->plimit(1); + $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql .= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { @@ -220,15 +220,15 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -$num=count($object->lines); +$num = count($object->lines); if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); + $form_question = array(); $delyear = GETPOST('delyear'); if (empty($delyear)) { @@ -249,7 +249,7 @@ if ($action == 'delbookkeepingyear') { } -print '
'; +print ''; print ''; print ''; if ($optioncss != '') print ''; @@ -259,11 +259,11 @@ print ''; print ''; -$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); @@ -335,7 +335,7 @@ while ($i < min($num, $limit)) //if (empty($accountg)) $accountg = '-'; // Is it a break ? - if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { + if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''; @@ -348,7 +348,7 @@ while ($i < min($num, $limit)) $colspan = 9; print ""; print ''; - if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); + if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print ''; print ''; @@ -373,20 +373,20 @@ while ($i < min($num, $limit)) // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; + print strlen(length_accounta($line->subledger_account)) == 0 ? ''.$line->label_operation.'' : ''.$line->label_operation.'
('.length_accounta($line->subledger_account).')'; - print '' . ($line->debit ? price($line->debit) :''). ''; - print '' . ($line->credit ? price($line->credit) : '') . ''; + print ''.($line->debit ? price($line->debit) : '').''; + print ''.($line->credit ? price($line->credit) : '').''; $accountingjournal = new AccountingJournal($db); $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print '' . $journaltoshow . ''; + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''.$journaltoshow.''; print ''; - print '' . img_edit() . ' '; - print '' . img_delete() . ''; + print ''.img_edit().' '; + print ''.img_delete().''; print ''; print "\n"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 1a212c00b84..0b3d98a2742 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -27,22 +27,22 @@ * \brief Tab to manage customer lettering */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","accountancy")); +$langs->loadLangs(array("compta", "accountancy")); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -139,15 +139,15 @@ dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'com $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; -$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )"; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; +$sql .= " WHERE (bk.subledger_account = '".$object->code_compta."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER."' )"; /* if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { @@ -155,7 +155,7 @@ if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { } */ -$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; +$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; $sql .= $db->order($sortfield, $sortorder); $debit = 0; @@ -186,8 +186,8 @@ if (!$resql) { exit(); } -$param=''; -$param.="&socid=".urlencode($socid); +$param = ''; +$param .= "&socid=".urlencode($socid); $num = $db->num_rows($resql); @@ -195,10 +195,10 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB if ($resql) { $i = 0; - $param="&socid=".$socid; - print ''; - print ''; - print ''; + $param = "&socid=".$socid; + print ''; + print ''; + print ''; $letteringbutton = ''; @@ -250,33 +250,33 @@ if ($resql) { $solde = 0; $tmp = ''; - while ( $obj = $db->fetch_object($resql) ) { + while ($obj = $db->fetch_object($resql)) { if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); print ''; //print '' . $obj->doc_type . '' . "\n"; - print '' . dol_print_date($db->jdate($obj->doc_date), 'day') . ''; - print '' . $obj->doc_ref . ''; - print '' . $obj->label_compte . ''; - print '' . price($obj->debit) . ''; - print '' . price($obj->credit) . ''; - print '' . price(round($solde, 2)) . ''; + print ''.dol_print_date($db->jdate($obj->doc_date), 'day').''; + print ''.$obj->doc_ref.''; + print ''.$obj->label_compte.''; + print ''.price($obj->debit).''; + print ''.price($obj->credit).''; + print ''.price(round($solde, 2)).''; // Journal $accountingjournal = new AccountingJournal($db); $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print '' . $journaltoshow . ''; + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''.$journaltoshow.''; if (empty($obj->lettering_code)) { - print ''; - print ''; + print ''; + print ''; print img_edit(); - print '' . "\n"; + print ''."\n"; } else { - print '' . $obj->lettering_code . ''; + print ''.$obj->lettering_code.''; print ''; } @@ -284,16 +284,16 @@ if ($resql) { } print ''; - print ''.$langs->trans("Total").':' . "\n"; - print '' . price($debit) . ''; - print '' . price($credit) . ''; + print ''.$langs->trans("Total").':'."\n"; + print ''.price($debit).''; + print ''.price($credit).''; print ''; print "\n"; print ''; - print ''.$langs->trans("Balancing").':' . "\n"; + print ''.$langs->trans("Balancing").':'."\n"; print ' '; - print '' . price($credit - $debit) . ''; + print ''.price($credit - $debit).''; print ''; print "\n"; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index f71b41a9c28..c6ab2fa81d6 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -26,22 +26,22 @@ * \brief Tab to setup lettering */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","accountancy")); +$langs->loadLangs(array("compta", "accountancy")); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref",'alpha'); $lettering = GETPOST('lettering', 'alpha'); if (!empty($lettering)) { - $action=$lettering; + $action = $lettering; } /* @@ -138,20 +138,20 @@ dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'com $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated "; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; -$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )"; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; +$sql .= " WHERE (bk.subledger_account = '".$object->code_compta_fournisseur."' AND bk.numero_compte = '".$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER."' )"; if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { $sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )"; } -$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; -$sql.= $db->order($sortfield, $sortorder); +$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')'; +$sql .= $db->order($sortfield, $sortorder); $debit = 0; $credit = 0; @@ -173,17 +173,17 @@ while ($obj = $db->fetch_object($resql)) { $solde += ($obj->credit - $obj->debit); } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) { +if (!$resql) { dol_print_error($db); exit; } -$param=''; -$param.="&socid=".urlencode($socid); +$param = ''; +$param .= "&socid=".urlencode($socid); $num = $db->num_rows($resql); @@ -193,10 +193,10 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param="&socid=".$socid; - print ''; - print ''; - print ''; + $param = "&socid=".$socid; + print ''; + print ''; + print ''; $letteringbutton = ''; @@ -254,26 +254,26 @@ if ($resql) { print ''; //print '' . $obj->doc_type . '' . "\n"; - print '' . dol_print_date($db->jdate($obj->doc_date), 'day') . ''; - print '' . $obj->doc_ref . ''; - print '' . $obj->label_compte . ''; - print '' . price($obj->debit) . ''; - print '' . price($obj->credit) . ''; - print '' . price(round($solde, 2)) . ''; + print ''.dol_print_date($db->jdate($obj->doc_date), 'day').''; + print ''.$obj->doc_ref.''; + print ''.$obj->label_compte.''; + print ''.price($obj->debit).''; + print ''.price($obj->credit).''; + print ''.price(round($solde, 2)).''; // Journal $accountingjournal = new AccountingJournal($db); $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print '' . $journaltoshow . ''; + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''.$journaltoshow.''; - if (empty($obj->lettering_code) && empty($obj->date_validated) ) { - print ''; - print ''; + if (empty($obj->lettering_code) && empty($obj->date_validated)) { + print ''; + print ''; print img_edit(); - print '' . "\n"; + print ''."\n"; } else { - print '' . $obj->lettering_code . ''; + print ''.$obj->lettering_code.''; print ''; } @@ -281,16 +281,16 @@ if ($resql) { } print ''; - print ''.$langs->trans("Total").':' . "\n"; - print '' . price($debit) . ''; - print '' . price($credit) . ''; + print ''.$langs->trans("Total").':'."\n"; + print ''.price($debit).''; + print ''.price($credit).''; print ''; print "\n"; print ''; - print ''.$langs->trans("Balancing").':' . "\n"; + print ''.$langs->trans("Balancing").':'."\n"; print ' '; - print '' . price($credit - $debit) . ''; + print ''.price($credit - $debit).''; print ''; print "\n"; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index eed3bb60e67..cc93232dcdc 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -24,7 +24,7 @@ */ // Class -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; /** * Class to manage categories of an accounting account @@ -49,12 +49,12 @@ class AccountancyCategory // extends CommonObject /** * @var string ID to identify managed object */ - public $element='c_accounting_category'; + public $element = 'c_accounting_category'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='c_accounting_category'; + public $table_element = 'c_accounting_category'; /** * @var int ID @@ -150,15 +150,15 @@ class AccountancyCategory // extends CommonObject public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->code)) $this->code=trim($this->code); - if (isset($this->label)) $this->label=trim($this->label); - if (isset($this->range_account)) $this->range_account=trim($this->range_account); + if (isset($this->code)) $this->code = trim($this->code); + if (isset($this->label)) $this->label = trim($this->label); + if (isset($this->range_account)) $this->range_account = trim($this->range_account); if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->category_type)) $this->category_type = (int) $this->category_type; - if (isset($this->formula)) $this->formula=trim($this->formula); + if (isset($this->formula)) $this->formula = trim($this->formula); if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; if (isset($this->active)) $this->active = (int) $this->active; @@ -168,47 +168,47 @@ class AccountancyCategory // extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category("; - if ($this->rowid > 0) $sql.= "rowid, "; - $sql.= "code, "; - $sql.= "label, "; - $sql.= "range_account, "; - $sql.= "sens, "; - $sql.= "category_type, "; - $sql.= "formula, "; - $sql.= "position, "; - $sql.= "fk_country, "; - $sql.= "active, "; - $sql.= "entity"; - $sql.= ") VALUES ("; - if ($this->rowid > 0) $sql.= " ".$this->rowid.","; - $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; - $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; - $sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").","; - $sql.= " ".(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").","; - $sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->db->escape($this->category_type)."'").","; - $sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").","; - $sql.= " ".(! isset($this->position)?'NULL':$this->db->escape($this->position)).","; - $sql.= " ".(! isset($this->fk_country)?'NULL':$this->db->escape($this->fk_country)).","; - $sql.= " ".(! isset($this->active)?'NULL':$this->db->escape($this->active)); - $sql.= ", ".$conf->entity; - $sql.= ")"; + if ($this->rowid > 0) $sql .= "rowid, "; + $sql .= "code, "; + $sql .= "label, "; + $sql .= "range_account, "; + $sql .= "sens, "; + $sql .= "category_type, "; + $sql .= "formula, "; + $sql .= "position, "; + $sql .= "fk_country, "; + $sql .= "active, "; + $sql .= "entity"; + $sql .= ") VALUES ("; + if ($this->rowid > 0) $sql .= " ".$this->rowid.","; + $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; + $sql .= " ".(!isset($this->range_account) ? 'NULL' : "'".$this->db->escape($this->range_account)."'").","; + $sql .= " ".(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").","; + $sql .= " ".(!isset($this->category_type) ? 'NULL' : "'".$this->db->escape($this->category_type)."'").","; + $sql .= " ".(!isset($this->formula) ? 'NULL' : "'".$this->db->escape($this->formula)."'").","; + $sql .= " ".(!isset($this->position) ? 'NULL' : $this->db->escape($this->position)).","; + $sql .= " ".(!isset($this->fk_country) ? 'NULL' : $this->db->escape($this->fk_country)).","; + $sql .= " ".(!isset($this->active) ? 'NULL' : $this->db->escape($this->active)); + $sql .= ", ".$conf->entity; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -229,27 +229,27 @@ class AccountancyCategory // extends CommonObject public function fetch($id, $code = '', $label = '') { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.code,"; - $sql.= " t.label,"; - $sql.= " t.range_account,"; - $sql.= " t.sens,"; - $sql.= " t.category_type,"; - $sql.= " t.formula,"; - $sql.= " t.position,"; - $sql.= " t.fk_country,"; - $sql.= " t.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; - if ($id) $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.range_account,"; + $sql .= " t.sens,"; + $sql .= " t.category_type,"; + $sql .= " t.formula,"; + $sql .= " t.position,"; + $sql .= " t.fk_country,"; + $sql .= " t.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; else { - $sql.= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid - if ($code) $sql.= " AND t.code = '".$this->db->escape($code)."'"; - elseif ($label) $sql.= " AND t.label = '".$this->db->escape($label)."'"; + $sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid + if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -273,7 +273,7 @@ class AccountancyCategory // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -289,15 +289,15 @@ class AccountancyCategory // extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->code)) $this->code=trim($this->code); - if (isset($this->label)) $this->label=trim($this->label); - if (isset($this->range_account)) $this->range_account=trim($this->range_account); + if (isset($this->code)) $this->code = trim($this->code); + if (isset($this->label)) $this->label = trim($this->label); + if (isset($this->range_account)) $this->range_account = trim($this->range_account); if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->category_type)) $this->category_type = (int) $this->category_type; - if (isset($this->formula)) $this->formula=trim($this->formula); + if (isset($this->formula)) $this->formula = trim($this->formula); if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; if (isset($this->active)) $this->active = (int) $this->active; @@ -308,33 +308,33 @@ class AccountancyCategory // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET"; - $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " range_account=".(isset($this->range_account)?"'".$this->db->escape($this->range_account)."'":"null").","; - $sql.= " sens=".(isset($this->sens)?$this->sens:"null").","; - $sql.= " category_type=".(isset($this->category_type)?$this->category_type:"null").","; - $sql.= " formula=".(isset($this->formula)?"'".$this->db->escape($this->formula)."'":"null").","; - $sql.= " position=".(isset($this->position)?$this->position:"null").","; - $sql.= " fk_country=".(isset($this->fk_country)?$this->fk_country:"null").","; - $sql.= " active=".(isset($this->active)?$this->active:"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " range_account=".(isset($this->range_account) ? "'".$this->db->escape($this->range_account)."'" : "null").","; + $sql .= " sens=".(isset($this->sens) ? $this->sens : "null").","; + $sql .= " category_type=".(isset($this->category_type) ? $this->category_type : "null").","; + $sql .= " formula=".(isset($this->formula) ? "'".$this->db->escape($this->formula)."'" : "null").","; + $sql .= " position=".(isset($this->position) ? $this->position : "null").","; + $sql .= " fk_country=".(isset($this->fk_country) ? $this->fk_country : "null").","; + $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -354,27 +354,27 @@ class AccountancyCategory // extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -394,28 +394,28 @@ class AccountancyCategory // extends CommonObject { global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id; - $sql .= " AND t.entity = " . $conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; + $sql .= " WHERE t.fk_accounting_category = ".$id; + $sql .= " AND t.entity = ".$conf->entity; $this->lines_display = array(); - dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); + dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $this->lines_display[] = $obj; } } return $num; } else { - $this->error = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -431,40 +431,40 @@ class AccountancyCategory // extends CommonObject global $conf; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; + $sql .= " WHERE t.fk_accounting_category = ".$id." AND t.entity = ".$conf->entity.")"; $sql .= " AND t.numero_compte IN ("; $sql .= " SELECT DISTINCT aa.account_number"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = " . $conf->entity . ")"; + $sql .= " AND aa.entity = ".$conf->entity.")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; - $this->lines_CptBk = array (); + $this->lines_CptBk = array(); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $this->lines_cptbk[] = $obj; } } return $num; } else { - $this->error = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -480,34 +480,34 @@ class AccountancyCategory // extends CommonObject global $conf; $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; - $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = " . $conf->entity; + $sql .= " AND aa.entity = ".$conf->entity; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; - $this->lines_CptBk = array (); + $this->lines_CptBk = array(); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $this->lines_cptbk[] = $obj; } } return $num; } else { - $this->error = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -527,42 +527,42 @@ class AccountancyCategory // extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $sql = "SELECT aa.rowid, aa.account_number"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = " . $conf->entity; - $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } - $accountincptsadded=array(); + $accountincptsadded = array(); while ($obj = $this->db->fetch_object($resql)) { - $account_number_formated=length_accountg($obj->account_number); - if (! empty($accountincptsadded[$account_number_formated])) continue; + $account_number_formated = length_accountg($obj->account_number); + if (!empty($accountincptsadded[$account_number_formated])) continue; if (array_key_exists($account_number_formated, $cpts)) { - $accountincptsadded[$account_number_formated]=1; + $accountincptsadded[$account_number_formated] = 1; // We found an account number that is in list $cpts of account to add - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; - $sql .= " SET fk_accounting_category=" . $id_cat; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; + $sql .= " SET fk_accounting_category=".$id_cat; $sql .= " WHERE rowid=".$obj->rowid; dol_syslog(__METHOD__, LOG_DEBUG); $resqlupdate = $this->db->query($sql); - if (! $resqlupdate) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resqlupdate) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } } } @@ -570,12 +570,12 @@ class AccountancyCategory // extends CommonObject // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -594,27 +594,27 @@ class AccountancyCategory // extends CommonObject { $error = 0; - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa"; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " SET fk_accounting_category= 0"; - $sql .= " WHERE aa.rowid= " . $cpt_id; + $sql .= " WHERE aa.rowid= ".$cpt_id; $this->db->begin(); - dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); + dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -637,14 +637,14 @@ class AccountancyCategory // extends CommonObject } $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; $sql .= " WHERE c.active = 1"; - $sql .= " AND c.entity = " . $conf->entity; + $sql .= " AND c.entity = ".$conf->entity; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND cat.rowid = t.fk_accounting_category"; - $sql .= " AND t.entity = " . $conf->entity; + $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); @@ -652,11 +652,11 @@ class AccountancyCategory // extends CommonObject $i = 0; $obj = ''; $num = $this->db->num_rows($resql); - $data = array (); + $data = array(); if ($num) { - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $name_cat = $obj->name_cat; - $data[$name_cat][$i] = array ( + $data[$name_cat][$i] = array( 'id' => $obj->rowid, 'code' => $obj->code, 'position' => $obj->position, @@ -664,13 +664,13 @@ class AccountancyCategory // extends CommonObject 'account_label' => $obj->account_label, 'sens' => $obj->sens ); - $i ++; + $i++; } } return $data; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); return -1; } @@ -696,34 +696,34 @@ class AccountancyCategory // extends CommonObject $this->sdcpermonth = array(); $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; - if (is_array($cpt)) $sql.=", t.numero_compte as accountancy_account"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; + if (is_array($cpt)) $sql .= ", t.numero_compte as accountancy_account"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; $sql .= " WHERE t.entity = ".$conf->entity; if (is_array($cpt)) { - $listofaccount=''; - foreach($cpt as $cptcursor) + $listofaccount = ''; + foreach ($cpt as $cptcursor) { - if ($listofaccount) $listofaccount.=","; - $listofaccount.="'".$cptcursor."'"; + if ($listofaccount) $listofaccount .= ","; + $listofaccount .= "'".$cptcursor."'"; } - $sql .= " AND t.numero_compte IN (" .$listofaccount. ")"; + $sql .= " AND t.numero_compte IN (".$listofaccount.")"; } else { - $sql .= " AND t.numero_compte = '" . $this->db->escape($cpt) . "'"; + $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; } - if (! empty($date_start) && ! empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end + if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')"; - if (! empty($month) && ! empty($year)) { + if (!empty($month) && !empty($year)) { $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')"; } if ($thirdparty_code != 'nofilter') { $sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'"; } - if (is_array($cpt)) $sql.=" GROUP BY t.numero_compte"; + if (is_array($cpt)) $sql .= " GROUP BY t.numero_compte"; //print $sql; $resql = $this->db->query($sql); @@ -745,9 +745,9 @@ class AccountancyCategory // extends CommonObject } return $num; } else { - $this->error = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); return -1; } } @@ -768,10 +768,10 @@ class AccountancyCategory // extends CommonObject } $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type, c.sens"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; $sql .= " WHERE c.active = 1"; - $sql .= " AND c.entity = " . $conf->entity; - if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; + $sql .= " AND c.entity = ".$conf->entity; + if ($categorytype >= 0) $sql .= " AND c.category_type = 1"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " ORDER BY c.position ASC"; @@ -780,12 +780,12 @@ class AccountancyCategory // extends CommonObject $i = 0; $obj = ''; $num = $this->db->num_rows($resql); - $data = array (); + $data = array(); if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - $data[] = array ( + $data[] = array( 'rowid' => $obj->rowid, 'code' => $obj->code, 'label' => $obj->label, @@ -799,11 +799,11 @@ class AccountancyCategory // extends CommonObject } return $data; } else { - $this->error = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -826,20 +826,20 @@ class AccountancyCategory // extends CommonObject exit(); } - if (! empty($cat_id)) + if (!empty($cat_id)) { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = ".$cat_id; - $sql .= " AND t.entity = " . $conf->entity; + $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY t.account_number"; } else { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE ".$predefinedgroupwhere; - $sql .= " AND t.entity = " . $conf->entity; + $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY t.account_number"; } //echo $sql; @@ -853,7 +853,7 @@ class AccountancyCategory // extends CommonObject if ($num) { while ($obj = $this->db->fetch_object($resql)) { - $data[] = array ( + $data[] = array( 'id' => $obj->rowid, 'account_number' => $obj->account_number, 'account_label' => $obj->account_label, @@ -863,8 +863,8 @@ class AccountancyCategory // extends CommonObject } return $data; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); return -1; } diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 6c628ae52c3..1e641564de4 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1079,28 +1079,28 @@ class AccountancyExport foreach ($objectLines as $line) { // TYPE C - if($last_codeinvoice != $line->doc_ref){ + if ($last_codeinvoice != $line->doc_ref) { //recherche societe en fonction de son code client - $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'"; + $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code."'"; $resql = $this->db->query($sql); - if($resql && $this->db->num_rows($resql)>0) + if ($resql && $this->db->num_rows($resql) > 0) { $soc = $this->db->fetch_object($resql); - $address=array('','',''); - if (strpos($soc->address, "\n")!==false) { + $address = array('', '', ''); + if (strpos($soc->address, "\n") !== false) { $address = explode("\n", $soc->address); - if (is_array($address) && count($address)>0) { - foreach($address as $key=>$data) { - $address[$key]=str_replace(array("\t", "\n", "\r"), "", $data); - $address[$key]=dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); + if (is_array($address) && count($address) > 0) { + foreach ($address as $key=>$data) { + $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); + $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); } } } else { - $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); - $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); - $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); + $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); + $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); + $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); } $type_enregistrement = 'C'; @@ -1254,7 +1254,7 @@ class AccountancyExport $racine_subledger_account = ''; // for records of type E leave this field blank // } - print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead + print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead // MONT print price(abs($line->montant), 0, '', 1, 2).$separator; // CODC diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 02d5f0bb183..719d33c8574 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -98,15 +98,15 @@ class AccountancySystem if ($rowid > 0 || $ref) { $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " WHERE"; if ($rowid) { - $sql .= " a.rowid = '" . $rowid . "'"; + $sql .= " a.rowid = '".$rowid."'"; } elseif ($ref) { - $sql .= " a.pcg_version = '" . $this->db->escape($ref) . "'"; + $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; } - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -124,11 +124,11 @@ class AccountancySystem return 0; } } else { - $this->error = "Error " . $this->db->lasterror(); - $this->errors[] = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } - return - 1; + return -1; } @@ -142,14 +142,14 @@ class AccountancySystem { $now = dol_now(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; $sql .= " (date_creation, fk_user_author, numero, label)"; - $sql .= " VALUES ('" . $this->db->idate($now) . "'," . $user->id . ",'" . $this->db->escape($this->numero) . "','" . $this->db->escape($this->label) . "')"; + $sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->numero)."','".$this->db->escape($this->label)."')"; - dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system"); if ($id > 0) { $this->rowid = $id; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index ff1e7ff8b72..a32918cc5bf 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -34,12 +34,12 @@ class AccountingAccount extends CommonObject /** * @var string Name of element */ - public $element='accounting_account'; + public $element = 'accounting_account'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='accounting_account'; + public $table_element = 'accounting_account'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -150,7 +150,7 @@ class AccountingAccount extends CommonObject global $conf; $this->db = $db; - $this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method + $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method } /** @@ -169,23 +169,23 @@ class AccountingAccount extends CommonObject if ($rowid || $account_number) { $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable"; $sql .= ", ca.label as category_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; $sql .= " WHERE"; if ($rowid) { - $sql .= " a.rowid = " . (int) $rowid; + $sql .= " a.rowid = ".(int) $rowid; } elseif ($account_number) { - $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; + $sql .= " a.account_number = '".$this->db->escape($account_number)."'"; $sql .= " AND a.entity = ".$conf->entity; } - if (! empty($limittocurrentchart)) { - $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; + if (!empty($limittocurrentchart)) { + $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; } - if (! empty($limittoachartaccount)) { + if (!empty($limittoachartaccount)) { $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; } - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -215,8 +215,8 @@ class AccountingAccount extends CommonObject return 0; } } else { - $this->error = "Error " . $this->db->lasterror(); - $this->errors[] = "Error " . $this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } return -1; @@ -255,7 +255,7 @@ class AccountingAccount extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_account("; $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -269,31 +269,31 @@ class AccountingAccount extends CommonObject $sql .= ", active"; $sql .= ", reconcilable"; $sql .= ") VALUES ("; - $sql .= " '" . $this->db->idate($now) . "'"; - $sql .= ", " . $conf->entity; - $sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); - $sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); - $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); - $sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent); - $sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'"); - $sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'"); - $sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= ", " . $user->id; - $sql .= ", " . (int) $this->active; - $sql .= ", " . (int) $this->reconcilable; + $sql .= " '".$this->db->idate($now)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'"); + $sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'"); + $sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'"); + $sql .= ", ".(empty($this->account_parent) ? 0 : (int) $this->account_parent); + $sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'"); + $sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'"); + $sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category); + $sql .= ", ".$user->id; + $sql .= ", ".(int) $this->active; + $sql .= ", ".(int) $this->reconcilable; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[] = "Error " . $this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_account"); // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -309,8 +309,8 @@ class AccountingAccount extends CommonObject // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -336,20 +336,20 @@ class AccountingAccount extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; - $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); - $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); - $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; - $sql .= " , account_parent = " . (int) $this->account_parent; - $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''"); - $sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''"); - $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= " , fk_user_modif = " . $user->id; - $sql .= " , active = " . (int) $this->active; - $sql .= " , reconcilable = " . (int) $this->reconcilable; - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; + $sql .= " SET fk_pcg_version = ".($this->fk_pcg_version ? "'".$this->db->escape($this->fk_pcg_version)."'" : "null"); + $sql .= " , pcg_type = ".($this->pcg_type ? "'".$this->db->escape($this->pcg_type)."'" : "null"); + $sql .= " , account_number = '".$this->db->escape($this->account_number)."'"; + $sql .= " , account_parent = ".(int) $this->account_parent; + $sql .= " , label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "''"); + $sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''"); + $sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category); + $sql .= " , fk_user_modif = ".$user->id; + $sql .= " , active = ".(int) $this->active; + $sql .= " , reconcilable = ".(int) $this->reconcilable; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -357,7 +357,7 @@ class AccountingAccount extends CommonObject } else { $this->error = $this->db->lasterror(); $this->db->rollback(); - return - 1; + return -1; } } @@ -370,13 +370,13 @@ class AccountingAccount extends CommonObject { global $langs; - $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; - $sql.= " WHERE fk_code_ventilation=" . $this->id . ")"; - $sql.= "UNION"; - $sql.= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql.= " WHERE fk_code_ventilation=" . $this->id . ")"; + $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; + $sql .= " WHERE fk_code_ventilation=".$this->id.")"; + $sql .= "UNION"; + $sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " WHERE fk_code_ventilation=".$this->id.")"; - dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::checkUsage sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -389,7 +389,7 @@ class AccountingAccount extends CommonObject } } else { $this->error = $this->db->lasterror(); - return - 1; + return -1; } } @@ -409,32 +409,32 @@ class AccountingAccount extends CommonObject if ($result > 0) { $this->db->begin(); - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account"; - $sql .= " WHERE rowid=" . $this->id; + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_account"; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::delete sql=" . $sql); + dol_syslog(get_class($this)."::delete sql=".$sql); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; } } else { - return - 1; + return -1; } } @@ -455,19 +455,19 @@ class AccountingAccount extends CommonObject global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$this->id; // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $picto = 'billr'; - $label=''; + $label = ''; if (empty($this->labelshort) || $withcompletelabel == 1) { @@ -476,28 +476,28 @@ class AccountingAccount extends CommonObject $labeltoshow = $this->labelshort; } - $label = '' . $langs->trans("ShowAccountingAccount") . ''; - if (! empty($this->account_number)) - $label .= '
'.$langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - if (! empty($labeltoshow)) - $label .= '
'.$langs->trans('Label') . ': ' . $labeltoshow; - if ($moretitle) $label.=' - '.$moretitle; + $label = ''.$langs->trans("ShowAccountingAccount").''; + if (!empty($this->account_number)) + $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + if (!empty($labeltoshow)) + $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + if ($moretitle) $label .= ' - '.$moretitle; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAccoutingAccount"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowAccoutingAccount"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; if ($nourl) { @@ -507,11 +507,11 @@ class AccountingAccount extends CommonObject } $label_link = length_accountg($this->account_number); - if ($withlabel) $label_link .= ' - ' . ($nourl ? '' : '').$labeltoshow.($nourl ? '' : ''); + if ($withlabel) $label_link .= ' - '.($nourl ? '' : '').$labeltoshow.($nourl ? '' : ''); - if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); + if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; + if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; return $result; } @@ -524,10 +524,10 @@ class AccountingAccount extends CommonObject public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; - $sql .= ' WHERE a.rowid = ' . $id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; + $sql .= ' WHERE a.rowid = '.$id; - dol_syslog(get_class($this) . '::info sql=' . $sql); + dol_syslog(get_class($this).'::info sql='.$sql); $result = $this->db->query($sql); if ($result) { @@ -578,11 +578,11 @@ class AccountingAccount extends CommonObject if ($result > 0) { $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; - $sql .= "SET " . $fieldtouse . " = '0'"; - $sql .= " WHERE rowid = " . $this->db->escape($id); + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; + $sql .= "SET ".$fieldtouse." = '0'"; + $sql .= " WHERE rowid = ".$this->db->escape($id); - dol_syslog(get_class($this) . "::account_desactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::account_desactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -591,10 +591,10 @@ class AccountingAccount extends CommonObject } else { $this->error = $this->db->lasterror(); $this->db->rollback(); - return - 1; + return -1; } } else { - return - 1; + return -1; } } @@ -620,11 +620,11 @@ class AccountingAccount extends CommonObject $fieldtouse = 'reconcilable'; } - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; - $sql .= "SET " . $fieldtouse . " = '1'"; - $sql .= " WHERE rowid = " . $this->db->escape($id); + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; + $sql .= "SET ".$fieldtouse." = '1'"; + $sql .= " WHERE rowid = ".$this->db->escape($id); - dol_syslog(get_class($this) . "::account_activate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -632,7 +632,7 @@ class AccountingAccount extends CommonObject } else { $this->error = $this->db->lasterror(); $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 2da8e4e24e1..43762c2d36a 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -361,20 +361,20 @@ class BookKeeping extends CommonObject $sql .= ", '".$this->db->escape($this->doc_ref)."'"; $sql .= ", ".$this->fk_doc; $sql .= ", ".$this->fk_docdet; - $sql .= ", ".(!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL"); - $sql .= ", ".(!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL"); - $sql .= ", ".(!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL"); + $sql .= ", ".(!empty($this->thirdparty_code) ? ("'".$this->db->escape($this->thirdparty_code)."'") : "NULL"); + $sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL"); + $sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->numero_compte)."'"; - $sql .= ", ".(!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL"); + $sql .= ", ".(!empty($this->label_operation) ? ("'".$this->db->escape($this->label_operation)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->label_operation)."'"; $sql .= ", ".$this->debit; $sql .= ", ".$this->credit; $sql .= ", ".$this->montant; - $sql .= ", ".(!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL"); + $sql .= ", ".(!empty($this->sens) ? ("'".$this->db->escape($this->sens)."'") : "NULL"); $sql .= ", '".$this->db->escape($this->fk_user_author)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->escape($this->code_journal)."'"; - $sql .= ", ".(!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL"); + $sql .= ", ".(!empty($this->journal_label) ? ("'".$this->db->escape($this->journal_label)."'") : "NULL"); $sql .= ", ".$this->db->escape($this->piece_num); $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; @@ -1397,7 +1397,7 @@ class BookKeeping extends CommonObject $sql = "DELETE"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE 1 = 1"; - $sql.= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear); + $sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear); if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; $sql .= " AND entity IN (".getEntity('accountancy').")"; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 88136ddea29..1909a8cd074 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -24,9 +24,9 @@ * \brief File of class for lettering */ -include_once DOL_DOCUMENT_ROOT . "/accountancy/class/bookkeeping.class.php"; -include_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php"; -include_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php"; +include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php"; +include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; /** * Class Lettering @@ -64,15 +64,15 @@ class Lettering extends BookKeeping $sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, "; $sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant "; $sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type "; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " WHERE ( "; if ($object->code_compta != "") - $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta."' "; if ($object->code_compta != "" && $object->code_compta_fournisseur != "") $sql .= " OR "; if ($object->code_compta_fournisseur != "") - $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; $sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) "; $sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) "; @@ -85,127 +85,127 @@ class Lettering extends BookKeeping if ($resql) { $num = $this->db->num_rows($resql); - while ($obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $ids = array(); $ids_fact = array(); if ($obj->type == 'payment_supplier') { $sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id'; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='" . $obj->code_journal . "')"; - $sql .= " WHERE payfacf.fk_paiementfourn = '" . $obj->url_id . "' "; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = payf.fk_bank AND bk.code_journal='".$obj->code_journal."')"; + $sql .= " WHERE payfacf.fk_paiementfourn = '".$obj->url_id."' "; $sql .= " AND facf.entity = ".$conf->entity; - $sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; + $sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND ( "; if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta."' "; } if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; } $sql .= " ) "; $resql2 = $this->db->query($sql); if ($resql2) { - while ( $obj2 = $this->db->fetch_object($resql2) ) { + while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; $ids_fact[] = $obj2->fact_id; } } else { $this->errors[] = $this->db->lasterror; - return - 1; + return -1; } if (count($ids_fact)) { $sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier '; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (" . implode(',', $ids_fact) . "))"; - $sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (".implode(',', $ids_fact)."))"; + $sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND ( "; if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta."' "; } if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; } $sql .= ") "; $resql2 = $this->db->query($sql); if ($resql2) { - while ( $obj2 = $this->db->fetch_object($resql2) ) { + while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } } else { $this->errors[] = $this->db->lasterror; - return - 1; + return -1; } } } elseif ($obj->type == 'payment') { $sql = 'SELECT DISTINCT bk.rowid, fac.ref, fac.ref, pay.fk_bank, fac.rowid as fact_id'; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')"; - $sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' "; - $sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; - $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facture fac "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='".$obj->code_journal."')"; + $sql .= " WHERE payfac.fk_paiement = '".$obj->url_id."' "; + $sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; + $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta."' "; } if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; } $sql .= " ) "; $resql2 = $this->db->query($sql); if ($resql2) { - while ( $obj2 = $this->db->fetch_object($resql2) ) { + while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; $ids_fact[] = $obj2->fact_id; } } else { $this->errors[] = $this->db->lasterror; - return - 1; + return -1; } if (count($ids_fact)) { $sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier '; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture fac "; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))"; - $sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; - $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facture fac "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (".implode(',', $ids_fact)."))"; + $sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; + $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta."' "; } if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { - $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; + $sql .= " bk.subledger_account = '".$object->code_compta_fournisseur."' "; } $sql .= " ) "; $resql2 = $this->db->query($sql); if ($resql2) { - while ( $obj2 = $this->db->fetch_object($resql2) ) { + while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } } else { $this->errors[] = $this->db->lasterror; - return - 1; + return -1; } } } @@ -217,10 +217,10 @@ class Lettering extends BookKeeping } if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::" . __METHOD__ . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::".__METHOD__.$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - return - 1 * $error; + return -1 * $error; } else { return 1; } @@ -237,33 +237,33 @@ class Lettering extends BookKeeping $error = 0; $lettre = 'AAA'; - dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $sql = "SELECT DISTINCT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; + $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1; "; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); - if (! empty($obj->lettering_code)) + if (!empty($obj->lettering_code)) $lettre++; } else { - $this->errors[] = 'Error' . $this->db->lasterror(); + $this->errors[] = 'Error'.$this->db->lasterror(); $error++; } - $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; - $sql .= " rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; + $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; + $sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL "; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - if (! (round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { - $this->errors[] = 'Total not exacts ' . round(abs($obj->deb), 2) . ' vs ' . round(abs($obj->cred), 2); + if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { + $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } } else { - $this->errors[] = 'Erreur sql' . $this->db->lasterror(); + $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; } @@ -271,30 +271,30 @@ class Lettering extends BookKeeping $now = dol_now(); - if (! $error) + if (!$error) { - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; - $sql .= " lettering_code='" . $lettre . "'"; - $sql .= " , date_lettering = '" . $this->db->idate($now) . "'"; // todo correct date it's false - $sql .= " WHERE rowid IN (" . implode(',', $ids) . ") AND date_validated IS NULL "; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; + $sql .= " lettering_code='".$lettre."'"; + $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false + $sql .= " WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL "; $this->db->begin(); - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[] = "Error " . $this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 19a5adcca34..eff348816fb 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -167,7 +167,7 @@ if ($action == 'validatehistory') { $suggestedaccountingaccountfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding + $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale $objp->code_sell_p = $objp->code_sell_intra; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index ec872726012..9dbb846370c 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -499,7 +499,7 @@ if ($result) { $suggestedaccountingaccountfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? + $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale $objp->code_sell_p = $objp->code_sell_intra; @@ -512,7 +512,7 @@ if ($result) { } } - if (! empty($objp->code_sell_p)) { + if (!empty($objp->code_sell_p)) { // Value was defined previously } else { $code_sell_p_notset = 'color:orange'; @@ -595,7 +595,7 @@ if ($result) { /*var_dump($suggestedid); var_dump($objp->code_sell_p); var_dump($objp->code_sell_l);*/ - if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) + if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) { @@ -632,7 +632,7 @@ if ($result) { print $db->error(); } if ($db->type == 'mysqli') { - $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation + $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation } // Add code to auto check the box when we select an account diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index ec193b2922a..bc0cf66a938 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -90,10 +90,10 @@ if ($conf->accounting->enabled) print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial); - print '
'; // hideobject is to start hidden + print '
'; // hideobject is to start hidden print "
\n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; - print "
\n";print "
\n"; + print "
\n"; print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; print '
'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index d849496d965..b3d1e6ce7f8 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -31,37 +31,37 @@ * \brief Page with bank journal */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; -require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php'; -require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","other","compta","banks","bills","donations","loan","accountancy","trips","salaries","hrm","members")); +$langs->loadLangs(array("companies", "other", "compta", "banks", "bills", "donations", "loan", "accountancy", "trips", "salaries", "hrm", "members")); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -95,13 +95,13 @@ $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; - $pastmonthyear --; + $pastmonthyear--; } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); @@ -112,26 +112,26 @@ $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_jour $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; $sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,"; $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; -$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; -$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; -$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= " JOIN ".MAIN_DB_PREFIX."bank_account as ba on b.fk_account=ba.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; +$sql .= " WHERE ba.fk_accountancy_journal=".$id_journal; +$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) - $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; + $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; // Already in bookkeeping or not if ($in_bookkeeping == 'already') { - $sql .= " AND (b.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; + $sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; } if ($in_bookkeeping == 'notyet') { - $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; + $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; } $sql .= " ORDER BY b.datev"; //print $sql; @@ -149,7 +149,7 @@ $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentvariousstatic = new PaymentVarious($db); $paymentloanstatic = new PaymentLoan($db); -$accountLinestatic=new AccountLine($db); +$accountLinestatic = new AccountLine($db); $paymentsubscriptionstatic = new Subscription($db); $tmppayment = new Paiement($db); @@ -171,20 +171,20 @@ if ($result) { //print $sql; // Variables - $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word - $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word - $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word - $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word - $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word - $account_pay_subscription = (! empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word - $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word + $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word + $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word + $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word $tabcompany = array(); $tabuser = array(); - $tabpay = array (); - $tabbq = array (); - $tabtp = array (); - $tabtype = array (); + $tabpay = array(); + $tabbq = array(); + $tabtp = array(); + $tabtype = array(); $tabmoreinfo = array(); // Loop on each line into llx_bank table. For each line, we should get: @@ -199,8 +199,8 @@ if ($result) { $lineisapurchase = -1; $lineisasale = -1; // Old method to detect if it's a sale or purchase - if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1; - if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1; + if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase = 1; + if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale = 1; // Try a more reliable method to detect if record is a supplier payment or a customer payment if ($lineisapurchase < 0) { @@ -221,9 +221,9 @@ if ($result) { if ($lineisapurchase > 0) $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier); if ($lineisasale > 0) - $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer); + $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $account_customer); - $tabcompany[$obj->rowid] = array ( + $tabcompany[$obj->rowid] = array( 'id' => $obj->socid, 'name' => $obj->name, 'code_compta' => $compta_soc, @@ -231,9 +231,9 @@ if ($result) { ); // Set accountancy code for user - $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); + $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); - $tabuser[$obj->rowid] = array ( + $tabuser[$obj->rowid] = array( 'id' => $obj->userid, 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'lastname' => $obj->lastname, @@ -244,8 +244,8 @@ if ($result) { // Variable bookkeeping ($obj->rowid is Bank Id) $tabpay[$obj->rowid]["date"] = $obj->do; - $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... - $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later + $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... + $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; @@ -254,14 +254,14 @@ if ($result) { } else { $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); } - $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) + $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) //var_dump($i); //var_dump($tabpay); //var_dump($tabcompany); // By default - $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. + $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url. $tabtype[$obj->rowid] = 'unknown'; $tabmoreinfo[$obj->rowid] = array(); @@ -287,18 +287,18 @@ if ($result) { } if ($links[$key]['type'] == 'withdraw') { - $tabmoreinfo[$obj->rowid]['withdraw']=1; + $tabmoreinfo[$obj->rowid]['withdraw'] = 1; } if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $paymentstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; } elseif ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; @@ -313,13 +313,13 @@ if ($result) { $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); - else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. + else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount; } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') $reg[1] = 'SocialContribution'; @@ -332,13 +332,13 @@ if ($result) { $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; $sqlmid = 'SELECT cchgsoc.accountancy_code'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc "; + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); @@ -348,14 +348,14 @@ if ($result) { $paymentdonstatic->id = $links[$key]['url_id']; $paymentdonstatic->ref = $links[$key]['url_id']; $paymentdonstatic->fk_donation = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; } elseif ($links[$key]['type'] == 'member') { $paymentsubscriptionstatic->id = $links[$key]['url_id']; $paymentsubscriptionstatic->ref = $links[$key]['url_id']; $paymentsubscriptionstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; @@ -363,14 +363,14 @@ if ($result) { $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; } elseif ($links[$key]['type'] == 'payment_expensereport') { $paymentexpensereportstatic->id = $links[$key]['url_id']; @@ -380,25 +380,25 @@ if ($result) { $paymentvariousstatic->id = $links[$key]['url_id']; $paymentvariousstatic->ref = $links[$key]['url_id']; $paymentvariousstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); - $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word - $account_subledger = (! empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word + $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $tabpay[$obj->rowid]["account_various"] = $account_various; $tabtp[$obj->rowid][$account_subledger] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2); + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; - $sqlmid.= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; - $sqlmid.= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid; + $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.$obj->rowid; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); @@ -408,7 +408,7 @@ if ($result) { } } elseif ($links[$key]['type'] == 'banktransfert') { $accountLinestatic->fetch($links[$key]['url_id']); - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- ' .$accountLinestatic ->getNomUrl(1); + $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); $tabtp[$obj->rowid][$account_transfer] += $obj->amount; $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); @@ -420,14 +420,14 @@ if ($result) { // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. - if (empty($tabtp[$obj->rowid]) && ! empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record + if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) // If we dont find 'company' link because it is an old 'withdraw' record { foreach ($links as $key => $val) { if ($links[$key]['type'] == 'payment') { // Get thirdparty $tmppayment->fetch($links[$key]['url_id']); $arrayofamounts = $tmppayment->getAmountsArray(); - foreach($arrayofamounts as $invoiceid => $amount) + foreach ($arrayofamounts as $invoiceid => $amount) { $tmpinvoice->fetch($invoiceid); $tmpinvoice->fetch_thirdparty(); @@ -478,7 +478,7 @@ var_dump($tabtp); var_dump($tabtype);*/ // Write bookkeeping -if (! $error && $action == 'writebookkeeping') { +if (!$error && $action == 'writebookkeeping') { $now = dol_now(); $error = 0; @@ -501,7 +501,7 @@ if (! $error && $action == 'writebookkeeping') { var_dump($tabbq);exit;*/ // Bank - if (! $errorforline && is_array($tabbq[$key])) + if (!$errorforline && is_array($tabbq[$key])) { // Line into bank account foreach ($tabbq[$key] as $k => $mt) @@ -509,9 +509,9 @@ if (! $error && $action == 'writebookkeeping') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; - $reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); - if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); + if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -528,7 +528,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0 ? $mt : 0); - $bookkeeping->credit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt < 0 ? -$mt : 0); $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; @@ -562,7 +562,7 @@ if (! $error && $action == 'writebookkeeping') { } // Third party - if (! $errorforline) + if (!$errorforline) { if (is_array($tabtp[$key])) { @@ -571,14 +571,14 @@ if (! $error && $action == 'writebookkeeping') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":""); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); if ($tabtype[$key] == 'banktransfert') { - $reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); } else { - $reflabel.= dol_string_nohtmltag($val['soclib']); + $reflabel .= dol_string_nohtmltag($val['soclib']); } $bookkeeping = new BookKeeping($db); @@ -590,7 +590,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->label_operation = $reflabel; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; @@ -598,15 +598,15 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_creation = $now; if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); @@ -715,8 +715,8 @@ if (! $error && $action == 'writebookkeeping') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; - $reflabel.= dol_string_nohtmltag('WaitingAccount'); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + $reflabel .= dol_string_nohtmltag('WaitingAccount'); $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -726,7 +726,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; @@ -767,7 +767,7 @@ if (! $error && $action == 'writebookkeeping') { setEventMessages('Try to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); } - if (! $errorforline) + if (!$errorforline) { $db->commit(); } @@ -776,11 +776,11 @@ if (! $error && $action == 'writebookkeeping') { //print 'KO for line '.$key.' '.$error.'
'; $db->rollback(); - $MAXNBERRORS=5; + $MAXNBERRORS = 5; if ($error >= $MAXNBERRORS) { setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); - break; // Break in the foreach + break; // Break in the foreach } } } @@ -802,15 +802,15 @@ if (! $error && $action == 'writebookkeeping') { // Must reload data, so we make a redirect if (count($tabpay) != $error) { - $param='id_journal='.$id_journal; - $param.='&date_startday='.$date_startday; - $param.='&date_startmonth='.$date_startmonth; - $param.='&date_startyear='.$date_startyear; - $param.='&date_endday='.$date_endday; - $param.='&date_endmonth='.$date_endmonth; - $param.='&date_endyear='.$date_endyear; - $param.='&in_bookkeeping='.$in_bookkeeping; - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); + $param = 'id_journal='.$id_journal; + $param .= '&date_startday='.$date_startday; + $param .= '&date_startmonth='.$date_startmonth; + $param .= '&date_startyear='.$date_startyear; + $param .= '&date_endday='.$date_endday; + $param .= '&date_endmonth='.$date_endmonth; + $param .= '&date_endyear='.$date_endyear; + $param .= '&in_bookkeeping='.$in_bookkeeping; + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); exit; } } @@ -823,20 +823,20 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $filename = 'journal'; $type_export = 'journal'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; // CSV header line - print '"' . $langs->transnoentitiesnoconv("BankId").'"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("PaymentMode") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("LedgerAccount") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("SubledgerAccount") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Label"). '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Journal") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Note") . '"' . $sep; + print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; print "\n"; foreach ($tabpay as $key => $val) @@ -850,21 +850,21 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; - $reflabel.= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); - if (! empty($val['soclib'])) $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); + if (!empty($val['soclib'])) $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print " " . $sep; - print '"' . $reflabel . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["type_payment"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print " ".$sep; + print '"'.$reflabel.'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'.$sep; + print '"'.dol_string_nohtmltag($ref).'"'.$sep; print "\n"; } } @@ -875,37 +875,37 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib']?" - ":""); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); if ($tabtype[$key] == 'banktransfert') { - $reflabel.= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); } else { - $reflabel.= dol_string_nohtmltag($val['soclib']); + $reflabel .= dol_string_nohtmltag($val['soclib']); } - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["type_payment"].'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; if ($tabtype[$key] == 'payment_supplier') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; - } elseif($tabtype[$key] == 'payment') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; - } elseif($tabtype[$key] == 'payment_expensereport') { - print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; - } elseif($tabtype[$key] == 'payment_salary') { - print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; + print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep; + } elseif ($tabtype[$key] == 'payment') { + print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep; + } elseif ($tabtype[$key] == 'payment_expensereport') { + print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep; + } elseif ($tabtype[$key] == 'payment_salary') { + print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep; } else { - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; } - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $reflabel . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$reflabel.'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'.$sep; + print '"'.dol_string_nohtmltag($ref).'"'.$sep; print "\n"; } } @@ -914,20 +914,20 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; - $reflabel.= dol_string_nohtmltag('WaitingAccount'); + if (!empty($val['lib'])) $reflabel .= dol_string_nohtmltag($val['lib'])." - "; + $reflabel .= dol_string_nohtmltag('WaitingAccount'); - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print "" . $sep; - print '"' . $reflabel . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["type_payment"].'"'.$sep; + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; + print "".$sep; + print '"'.$reflabel.'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'.$sep; + print '"'.dol_string_nohtmltag($ref).'"'.$sep; print "\n"; } } @@ -954,16 +954,16 @@ if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("FinanceJournal")); - $nom = $langs->trans("FinanceJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); - $builddate=dol_now(); + $nom = $langs->trans("FinanceJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); + $builddate = dol_now(); //$description = $langs->trans("DescFinanceJournal") . '
'; - $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; + $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; - $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); - $varlink = 'id_journal=' . $id_journal; + $varlink = 'id_journal='.$id_journal; journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); @@ -994,15 +994,15 @@ if (empty($action) || $action == 'view') { print '
'; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print ''; + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print '' . $langs->trans("WriteBookKeeping") . ''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; @@ -1033,14 +1033,14 @@ if (empty($action) || $action == 'view') { print '
'; print ""; print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print '"; - print '"; - print '"; + print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; + print '"; print "\n"; $r = ''; @@ -1057,15 +1057,15 @@ if (empty($action) || $action == 'view') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - "; - $reflabel.= $langs->trans("Bank").' '.$val['bank_account_ref']; - if (! empty($val['soclib'])) $reflabel .= " - " . $val['soclib']; + if (!empty($val['lib'])) $reflabel .= $val['lib']." - "; + $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; + if (!empty($val['soclib'])) $reflabel .= " - ".$val['soclib']; //var_dump($tabpay[$key]); print ''; print ''; - print ""; - print ""; + print ""; + print ""; // Ledger account print ""; - print '"; - print '"; - print '"; + print '"; + print '"; + print '"; print ""; } } @@ -1100,20 +1100,20 @@ if (empty($action) || $action == 'view') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= $val['lib'] . ($val['soclib']?" - ":""); + if (!empty($val['lib'])) $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); if ($tabtype[$key] == 'banktransfert') { - $reflabel.= $langs->trans('TransitionalAccount').' '.$account_transfer; + $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; } else { - $reflabel.= $val['soclib']; + $reflabel .= $val['soclib']; } print ''; print ''; - print ""; - print ""; + print ""; + print ""; // Ledger account print ""; - print ""; - print '"; - print '"; - print '"; + print ""; + print '"; + print '"; + print '"; print ""; } } @@ -1199,13 +1199,13 @@ if (empty($action) || $action == 'view') { if ($mt) { $reflabel = ''; - if (! empty($val['lib'])) $reflabel .= $val['lib'] . " - "; - $reflabel.= 'WaitingAccount'; + if (!empty($val['lib'])) $reflabel .= $val['lib']." - "; + $reflabel .= 'WaitingAccount'; print ''; print ''; - print ""; - print ""; + print ""; + print ""; // Ledger account print ""; - print ""; - print '"; - print '"; - print '"; + print ""; + print '"; + print '"; + print '"; print ""; } } @@ -1287,63 +1287,63 @@ function getSourceDocRef($val, $typerecord) { $sqlmid = 'SELECT payfac.fk_facture as id, f.ref as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; - $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; + $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=".$val["paymentid"]; $ref = $langs->transnoentitiesnoconv("Invoice"); } elseif ($typerecord == 'payment_supplier') { $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"]; $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); } elseif ($typerecord == 'payment_expensereport') { $sqlmid = 'SELECT e.rowid as id, e.ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; - $sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; + $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; $ref = $langs->transnoentitiesnoconv("ExpenseReport"); } elseif ($typerecord == 'payment_salary') { $sqlmid = 'SELECT s.rowid as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; - $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"]; $ref = $langs->transnoentitiesnoconv("SalaryPayment"); } elseif ($typerecord == 'sc') { $sqlmid = 'SELECT sc.rowid as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; - $sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; + $sqlmid .= " WHERE sc.rowid=".$val["paymentscid"]; $ref = $langs->transnoentitiesnoconv("SocialContribution"); } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; - $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; + $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"]; $ref = $langs->transnoentitiesnoconv("PaymentVat"); } elseif ($typerecord == 'payment_donation') { $sqlmid = 'SELECT payd.fk_donation as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; - $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; + $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"]; $ref = $langs->transnoentitiesnoconv("Donation"); } elseif ($typerecord == 'payment_loan') { $sqlmid = 'SELECT l.rowid as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; - $sqlmid .= " WHERE l.rowid=" . $val["paymentloanid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; + $sqlmid .= " WHERE l.rowid=".$val["paymentloanid"]; $ref = $langs->transnoentitiesnoconv("LoanPayment"); } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; - $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; + $sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"]; $ref = $langs->transnoentitiesnoconv("VariousPayment"); } // Add warning @@ -1354,18 +1354,18 @@ function getSourceDocRef($val, $typerecord) if ($sqlmid) { - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { while ($objmid = $db->fetch_object($resultmid)) { - $ref.=' '.$objmid->ref; + $ref .= ' '.$objmid->ref; } } else dol_print_error($db); } - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 return $ref; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 29131274c7a..d0a84c1236c 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') { $accountingaccount->fetch($k, null, true); $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'; + $bookkeeping->label_operation = $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -448,36 +448,36 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k, true); if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; print "\n"; } } // VAT foreach ($tabtva[$key] as $k => $mt) { if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($langs->trans("VAT")) . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; print "\n"; } } // Third party foreach ($tabttc[$key] as $k => $mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($userstatic->name) . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($userstatic->name).'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'; } print "\n"; } @@ -641,8 +641,8 @@ if (empty($action) || $action == 'view') { if ($mt) { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print '"; + print '"; print ""; } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c7fb4c06304..dd7dc1ca9e1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -301,7 +301,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; @@ -310,7 +310,7 @@ if ($action == 'writebookkeeping') { $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; @@ -329,14 +329,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -344,7 +344,7 @@ if ($action == 'writebookkeeping') { } // Product / Service - if (! $errorforline) + if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { // get compte id and label @@ -356,13 +356,13 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -381,14 +381,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -398,10 +398,10 @@ if ($action == 'writebookkeeping') { // VAT // var_dump($tabtva); - if (! $errorforline) + if (!$errorforline) { - $listoftax=array(0, 1, 2); - foreach($listoftax as $numtax) + $listoftax = array(0, 1, 2); + foreach ($listoftax as $numtax) { $arrayofvat = $tabtva; if ($numtax == 1) $arrayofvat = $tablocaltax1; @@ -416,7 +416,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -425,7 +425,7 @@ if ($action == 'writebookkeeping') { $accountingaccount->fetch($k, null, true); $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:''); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -444,14 +444,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -462,7 +462,7 @@ if ($action == 'writebookkeeping') { // Counterpart of VAT for VAT NPR // var_dump($tabother); - if (! $errorforline && is_array($tabother[$key])) + if (!$errorforline && is_array($tabother[$key])) { foreach ($tabother[$key] as $k => $mt) { if ($mt) { @@ -478,7 +478,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT").' NPR'; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' NPR'; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -513,7 +513,7 @@ if ($action == 'writebookkeeping') { } // Protection against a bug on lines before - if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) + if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) { $error++; $errorforline++; @@ -863,8 +863,8 @@ if (empty($action) || $action == 'view') { foreach ($tabttc[$key] as $k => $mt) { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } @@ -896,8 +896,8 @@ if (empty($action) || $action == 'view') { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 878270d3687..80603106cb3 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -99,31 +99,31 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_r $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE fd.fk_code_ventilation > 0"; -$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing +$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing $sql .= " AND f.fk_statut > 0"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } $sql .= " AND fd.product_type IN (0,1)"; 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)."'"; // Already in bookkeeping or not if ($in_bookkeeping == 'already') { - $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; + $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // $sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } if ($in_bookkeeping == 'notyet') { - $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; + $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } $sql .= " ORDER BY f.datef"; @@ -312,7 +312,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; @@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') { $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -340,14 +340,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -355,7 +355,7 @@ if ($action == 'writebookkeeping') { } // Product / Service - if (! $errorforline) + if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { // get compte id and label @@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? -$mt : 0; @@ -408,10 +408,10 @@ if ($action == 'writebookkeeping') { } // VAT - if (! $errorforline) + if (!$errorforline) { - $listoftax=array(0, 1, 2); - foreach($listoftax as $numtax) + $listoftax = array(0, 1, 2); + foreach ($listoftax as $numtax) { $arrayofvat = $tabtva; if ($numtax == 1) $arrayofvat = $tablocaltax1; @@ -426,7 +426,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -435,7 +435,7 @@ if ($action == 'writebookkeeping') { $accountingaccount->fetch($k, null, true); $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:''); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? -$mt : 0; @@ -471,7 +471,7 @@ if ($action == 'writebookkeeping') { } // Protection against a bug on lines before - if (! $errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) + if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) { $error++; $errorforline++; @@ -799,8 +799,8 @@ if (empty($action) || $action == 'view') { { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } @@ -833,8 +833,8 @@ if (empty($action) || $action == 'view') { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 72c1e078ba0..6b2d432fe46 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -34,12 +34,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","members")); +$langs->loadLangs(array("admin", "members")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$type=array('yesno','texte','chaine'); +$type = array('yesno', 'texte', 'chaine'); $action = GETPOST('action', 'alpha'); @@ -52,19 +52,19 @@ $action = GETPOST('action', 'alpha'); if ($action == 'updateall') { $db->begin(); - $res1=$res2=$res3=$res4=$res5=$res6=0; - $res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha')?0:1, 'chaine', 0, '', $conf->entity); - $res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - $res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation if ($conf->facture->enabled) { - $res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); } } if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) @@ -82,23 +82,23 @@ if ($action == 'updateall') // Action to update or add a constant if ($action == 'update' || $action == 'add') { - $constname=GETPOST('constname', 'alpha'); - $constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); + $constname = GETPOST('constname', 'alpha'); + $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); - if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue=''; - if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice + if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = ''; + if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice { - if ($constvalue) $constvalue=0; - else $constvalue=1; + if ($constvalue) $constvalue = 0; + else $constvalue = 1; } - $consttype=GETPOST('consttype', 'alpha'); - $constnote=GETPOST('constnote'); - $res=dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); + $consttype = GETPOST('consttype', 'alpha'); + $constnote = GETPOST('constnote'); + $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -111,7 +111,7 @@ if ($action == 'update' || $action == 'add') // Action to enable of a submodule of the adherent module if ($action == 'set') { - $result=dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); + $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); if ($result < 0) { print $db->error(); @@ -121,7 +121,7 @@ if ($action == 'set') // Action to disable a submodule of the adherent module if ($action == 'unset') { - $result=dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); + $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); if ($result < 0) { print $db->error(); @@ -136,12 +136,12 @@ if ($action == 'unset') $form = new Form($db); -$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('', $langs->trans("MembersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); @@ -162,25 +162,25 @@ print "\n"; // Login/Pass required for members print '\n"; // Mail required for members print '\n"; // Send mail information is on by default print '\n"; // Insert subscription into bank account print ''; -$arraychoices=array('0'=>$langs->trans("None")); -if (! empty($conf->banque->enabled)) $arraychoices['bankdirect']=$langs->trans("MoreActionBankDirect"); -if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $arraychoices['invoiceonly']=$langs->trans("MoreActionInvoiceOnly"); -if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $arraychoices['bankviainvoice']=$langs->trans("MoreActionBankViaInvoice"); +$arraychoices = array('0'=>$langs->trans("None")); +if (!empty($conf->banque->enabled)) $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect"); +if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly"); +if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice"); print '\n"; if ($conf->facture->enabled) { print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; } else @@ -208,7 +208,7 @@ if ($conf->facture->enabled) } print "\n"; - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { print ''; print '\n"; // Amount print '\n"; // Can edit print '\n"; // Jump to an online payment page print '\n"; print '
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")" . $langs->trans("AccountAccounting") . "" . $langs->trans("SubledgerAccount") . "" . $langs->trans("LabelOperation") . "' . $langs->trans("PaymentMode") . "' . $langs->trans("Debit") . "' . $langs->trans("Credit") . "".$langs->trans("Date")."".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")".$langs->trans("AccountAccounting")."".$langs->trans("SubledgerAccount")."".$langs->trans("LabelOperation")."'.$langs->trans("PaymentMode")."'.$langs->trans("Debit")."'.$langs->trans("Credit")."
" . $date . "" . $ref . "".$date."".$ref.""; $accounttoshow = length_accountg($k); @@ -1087,9 +1087,9 @@ if (empty($action) || $action == 'view') { print ""; print $reflabel; print "' . $val["type_payment"] . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "'.$val["type_payment"]."'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $ref . "".$date."".$ref.""; $account_ledger = $k; @@ -1137,19 +1137,19 @@ if (empty($action) || $action == 'view') { } else { - print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account + print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account } } else { // We will refuse writing - $errorstring='UnknownAccountForThirdpartyBlocking'; - if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; - if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; - if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; - if ($tabtype[$key] == 'payment_vat') $errorstring='MainAccountForVatPaymentNotDefined'; - if ($tabtype[$key] == 'member') $errorstring='MainAccountForSubscriptionPaymentNotDefined'; + $errorstring = 'UnknownAccountForThirdpartyBlocking'; + if ($tabtype[$key] == 'payment') $errorstring = 'MainAccountForCustomersNotDefined'; + if ($tabtype[$key] == 'payment_supplier') $errorstring = 'MainAccountForSuppliersNotDefined'; + if ($tabtype[$key] == 'payment_expensereport') $errorstring = 'MainAccountForUsersNotDefined'; + if ($tabtype[$key] == 'payment_salary') $errorstring = 'MainAccountForUsersNotDefined'; + if ($tabtype[$key] == 'payment_vat') $errorstring = 'MainAccountForVatPaymentNotDefined'; + if ($tabtype[$key] == 'member') $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; print ''.$langs->trans($errorstring).''; } } @@ -1169,7 +1169,7 @@ if (empty($action) || $action == 'view') { var_dump($tabtype[$key]); var_dump($tabbq[$key]);*/ //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - if (! empty($tabcompany[$key]['code_compta'])) + if (!empty($tabcompany[$key]['code_compta'])) { if (in_array($tabtype[$key], array('payment_various'))) { // For such case, if subledger is not defined, we won't use subledger accounts. @@ -1187,10 +1187,10 @@ if (empty($action) || $action == 'view') { } } print "" . $reflabel . "' . $val["type_payment"] . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$reflabel."'.$val["type_payment"]."'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
" . $date . "" . $ref . "".$date."".$ref.""; /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') @@ -1223,10 +1223,10 @@ if (empty($action) || $action == 'view') { else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); */ print "" . $reflabel . "' . $val["type_payment"] . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$reflabel."'.$val["type_payment"]."'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
" . $date . "" . $expensereportstatic->getNomUrl(1) . "".$date."".$expensereportstatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -655,10 +655,10 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); + print "".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); print "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER); @@ -883,9 +883,9 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print '" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("SubledgerAccount") . "'. ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -912,9 +912,9 @@ if (empty($action) || $action == 'view') { print '" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label."'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER); @@ -819,9 +819,9 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -849,9 +849,9 @@ if (empty($action) || $action == 'view') { print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label."'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'.$langs->trans("AdherentLoginRequired").''; -print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (! empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)?0:1), 1); +print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1); print "
'.$langs->trans("AdherentMailRequired").''; -print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (! empty($conf->global->ADHERENT_MAIL_REQUIRED)?$conf->global->ADHERENT_MAIL_REQUIRED:0), 1); +print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1); print "
'.$langs->trans("MemberSendInformationByMailByDefault").''; -print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL:0), 1); +print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); print "
'.$langs->trans("MoreActionsOnSubscription").''; print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') @@ -194,10 +194,10 @@ print "
'.$langs->trans("VATToUseForSubscriptions").''; - print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"),'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS)?'0':$conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0); + print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0); print '
'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; @@ -232,7 +232,7 @@ print '
'; /* * Edit info of model document */ -$constantes=array( +$constantes = array( 'ADHERENT_CARD_TYPE', // 'ADHERENT_CARD_BACKGROUND', 'ADHERENT_CARD_HEADER_TEXT', @@ -243,10 +243,10 @@ $constantes=array( print load_fiche_titre($langs->trans("MembersCards"), '', ''); -$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; -$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; -$helptext.='__YEAR__, __MONTH__, __DAY__'; +$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext .= '__YEAR__, __MONTH__, __DAY__'; form_constantes($constantes, 0, $helptext); @@ -256,14 +256,14 @@ print '
'; /* * Edit info of model document */ -$constantes=array('ADHERENT_ETIQUETTE_TYPE','ADHERENT_ETIQUETTE_TEXT'); +$constantes = array('ADHERENT_ETIQUETTE_TYPE', 'ADHERENT_ETIQUETTE_TEXT'); print load_fiche_titre($langs->trans("MembersTickets"), '', ''); -$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; -$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; -$helptext.='__YEAR__, __MONTH__, __DAY__'; +$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext .= '__YEAR__, __MONTH__, __DAY__'; form_constantes($constantes, 0, $helptext); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index 9fef348315b..e0675a6124a 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -34,25 +34,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","members")); +$langs->loadLangs(array("admin", "members")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$oldtypetonewone=array('texte'=>'text','chaine'=>'string'); // old type to new ones +$oldtypetonewone = array('texte'=>'text', 'chaine'=>'string'); // old type to new ones $action = GETPOST('action', 'alpha'); $error = 0; // Editing global variables not related to a specific theme -$constantes=array( +$constantes = array( 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member', - 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ - 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ - 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ - 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ + 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */ + 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */ + 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */ + 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */ 'ADHERENT_MAIL_FROM'=>'string', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string', 'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html', @@ -68,8 +68,8 @@ $constantes=array( if ($action == 'updateall') { $db->begin(); - $res1=$res2=$res3=$res4=$res5=$res6=0; - $res1=dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); @@ -86,19 +86,19 @@ if ($action == 'updateall') if ($action == 'update' || $action == 'add') { $constlineid = GETPOST('rowid', 'int'); - $constname=GETPOST('constname', 'alpha'); + $constname = GETPOST('constname', 'alpha'); - $constvalue=(GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue')); - $consttype=(GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype')); - $constnote=(GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote')); + $constvalue = (GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue')); + $consttype = (GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype')); + $constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote')); $typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype]; - $res=dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity); + $res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -111,7 +111,7 @@ if ($action == 'update' || $action == 'add') // Action to enable a submodule of the adherent module if ($action == 'set') { - $result=dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); + $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); if ($result < 0) { print $db->error(); @@ -121,7 +121,7 @@ if ($action == 'set') // Action to disable a submodule of the adherent module if ($action == 'unset') { - $result=dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); + $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); if ($result < 0) { print $db->error(); @@ -136,12 +136,12 @@ if ($action == 'unset') $form = new Form($db); -$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('', $langs->trans("MembersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); @@ -154,9 +154,9 @@ dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user'); //print ''; //print ''; -$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; -$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +$helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; //$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported form_constantes($constantes, 0, $helptext); diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index 6f2b899dc5c..73e1a519c59 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -29,19 +29,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","members")); +$langs->loadLangs(array("admin", "members")); $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='adherent'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'adherent'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -60,11 +60,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("Members"); -$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('', $langs->trans("MembersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); @@ -105,7 +105,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print '

'; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index cd73320d02d..7864505f2e1 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -32,19 +32,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","members")); +$langs->loadLangs(array("admin", "members")); $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='adherent_type'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -61,13 +61,13 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("MembersTypes"); +$textobject = $langs->transnoentitiesnoconv("MembersTypes"); -$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('', $langs->trans("MembersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); @@ -108,7 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index a2eead267af..a8cdc06784e 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,34 +178,34 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) $listofval = array(); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; - print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); + print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0); print "
'; print $langs->trans("DefaultAmount"); print ''; - print ''; + print ''; print "
'; print $langs->trans("CanEditAmount"); print ''; - print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)?$conf->global->MEMBER_NEWFORM_EDITAMOUNT:0), 1); + print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1); print "
'; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); print ''; - $listofval=array(); - $listofval['-1']=$langs->trans('No'); - $listofval['all']=$langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; - if (! empty($conf->paybox->enabled)) $listofval['paybox']='Paybox'; - if (! empty($conf->paypal->enabled)) $listofval['paypal']='PayPal'; - if (! empty($conf->stripe->enabled)) $listofval['stripe']='Stripe'; - print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)?$conf->global->MEMBER_NEWFORM_PAYONLINE:''), 0); + $listofval = array(); + $listofval['-1'] = $langs->trans('No'); + $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; + if (!empty($conf->paybox->enabled)) $listofval['paybox'] = 'Paybox'; + if (!empty($conf->paypal->enabled)) $listofval['paypal'] = 'PayPal'; + if (!empty($conf->stripe->enabled)) $listofval['stripe'] = 'Stripe'; + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0); print "
'; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 019f35f2908..20d712e6179 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -149,24 +149,24 @@ if ($object->id > 0) $newcardbutton = ''; - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { - $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); } - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; - $param='&id='.$id; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 0f954ecf201..eeee48e2138 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -45,7 +45,7 @@ abstract class ActionsAdherentCardCommon /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -70,7 +70,7 @@ abstract class ActionsAdherentCardCommon else {*/ $object = new Adherent($this->db); - if (! empty($id)) $object->fetch($id); + if (!empty($id)) $object->fetch($id); $this->object = $object; //} } @@ -91,13 +91,13 @@ abstract class ActionsAdherentCardCommon if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach($this->object as $key => $value) + foreach ($this->object as $key => $value) { $this->tpl[$key] = $value; } - $this->tpl['error']=$this->error; - $this->tpl['errors']=$this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'create' || $action == 'edit') { @@ -139,10 +139,10 @@ abstract class ActionsAdherentCardCommon } // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode','selectcountry_id','state_id')); + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; @@ -157,14 +157,14 @@ abstract class ActionsAdherentCardCommon else $this->tpl['select_state'] = $countrynotdefined; // Physical or Moral - $selectarray=array('0'=>$langs->trans("Physical"),'1'=>$langs->trans("Moral")); + $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); } if ($action == 'view' || $action == 'edit' || $action == 'delete') { // Emailing - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); @@ -173,8 +173,8 @@ abstract class ActionsAdherentCardCommon // Dolibarr user if ($this->object->user_id) { - $dolibarr_user=new User($this->db); - $result=$dolibarr_user->fetch($this->object->user_id); + $dolibarr_user = new User($this->db); + $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); @@ -200,14 +200,14 @@ abstract class ActionsAdherentCardCommon $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip?$this->object->zip.' ':''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img=picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img?$img.' ':'').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); @@ -219,13 +219,13 @@ abstract class ActionsAdherentCardCommon // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login=dol_buildlogin($this->object->lastname, $this->object->firstname); + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password=getRandomPassword(false); - $password=$generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; // Create a form array - $formquestion=array( + $formquestion = array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); @@ -244,35 +244,35 @@ abstract class ActionsAdherentCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->fk_soc = $_POST["fk_soc"]; $this->object->lastname = $_POST["lastname"]; $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; $this->object->email = $_POST["email"]; $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; } else { diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index eb295431e8d..60bb2ecd034 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -42,7 +42,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $db; - $this->dirmodule = $dirmodule; + $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; $this->card = $card; @@ -56,13 +56,13 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ private function getTitle($action) { - global $langs,$conf; + global $langs, $conf; - $out=''; + $out = ''; - if ($action == 'view') $out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress")); - if ($action == 'edit') $out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress")); - if ($action == 'create') $out.= (! empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress")); + if ($action == 'view') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress")); + if ($action == 'edit') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress")); + if ($action == 'create') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress")); return $out; } @@ -88,7 +88,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['title'] = $this->getTitle($action); $this->tpl['error'] = $this->error; - $this->tpl['errors']= $this->errors; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { @@ -96,15 +96,15 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $head = member_prepare_head($this->object); $title = $this->getTitle($action); - $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); - $this->tpl['showend']=dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); + $this->tpl['showend'] = dol_get_fiche_end(); $objsoc = new Societe($db); $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo']=show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone']=show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php index dcab3116f53..92f1e11d7a2 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_create.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; @@ -30,9 +30,9 @@ if (empty($conf) || ! is_object($conf)) control->tpl['title']); -dol_htmloutput_errors((is_numeric($object->error)?'':$object->error), $object->errors); +dol_htmloutput_errors((is_numeric($object->error) ? '' : $object->error), $object->errors); -dol_htmloutput_errors((is_numeric($GLOBALS['error'])?'':$GLOBALS['error']), $GLOBALS['errors']); +dol_htmloutput_errors((is_numeric($GLOBALS['error']) ? '' : $GLOBALS['error']), $GLOBALS['errors']); dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']); diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php index d49d43825bb..36e2deab14c 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.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; @@ -48,7 +48,7 @@ echo $this->control->tpl['ajax_selectcountry']; -control->tpl['company_id'])) { ?> +control->tpl['company_id'])) { ?> diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 51f121ad903..b738f549247 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.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; @@ -30,8 +30,8 @@ echo "\n"; echo $this->control->tpl['showhead']; dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']); -if (! empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; -if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> +if (!empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; +if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> @@ -125,7 +125,7 @@ if (empty($user->socid)) { echo ''.$langs->trans('Modify').''; } - if (! $this->control->tpl['user_id'] && $user->rights->user->user->creer) { + if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { echo ''.$langs->trans("CreateDolibarrLogin").''; } diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 6736a22cd5d..86bf523ac51 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; -$langs->loadLangs(array("members","errors")); +$langs->loadLangs(array("members", "errors")); // Choice of printing year or current year. $now = dol_now(); -$year=dol_print_date($now, '%Y'); -$month=dol_print_date($now, '%m'); -$day=dol_print_date($now, '%d'); -$foruserid=GETPOST('foruserid', 'alphanohtml'); -$foruserlogin=GETPOST('foruserlogin', 'alphanohtml'); -$mode=GETPOST('mode', 'aZ09'); -$model=GETPOST("model", 'aZ09'); // Doc template to use for business cards -$modellabel=GETPOST("modellabel", 'aZ09'); // Doc template to use for address sheet -$mesg=''; +$year = dol_print_date($now, '%Y'); +$month = dol_print_date($now, '%m'); +$day = dol_print_date($now, '%d'); +$foruserid = GETPOST('foruserid', 'alphanohtml'); +$foruserlogin = GETPOST('foruserlogin', 'alphanohtml'); +$mode = GETPOST('mode', 'aZ09'); +$model = GETPOST("model", 'aZ09'); // Doc template to use for business cards +$modellabel = GETPOST("modellabel", 'aZ09'); // Doc template to use for address sheet +$mesg = ''; -$adherentstatic=new Adherent($db); -$object=new Adherent($db); +$adherentstatic = new Adherent($db); +$object = new Adherent($db); $extrafields = new ExtraFields($db); // Fetch optionals attributes and labels @@ -57,29 +57,29 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($mode == 'cardlogin' && empty($foruserlogin)) { - $mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); } -if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg) +if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { - $arrayofmembers=array(); + $arrayofmembers = array(); // request taking into account member with up to date subscriptions $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; - $sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; - $sql.= " t.libelle as type,"; - $sql.= " c.code as country_code, c.label as country"; + $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; + $sql .= " t.libelle as type,"; + $sql .= " c.code as country_code, c.label as country"; // 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 : ''); - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; - $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; - $sql.= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; - if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'"; - $sql.= " ORDER BY d.rowid ASC"; + 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 : ''); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; + $sql .= " ORDER BY d.rowid ASC"; dol_syslog("Search members", LOG_DEBUG); $result = $db->query($sql); @@ -91,19 +91,19 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg { $objp = $db->fetch_object($result); - if ($objp->country == '-') $objp->country=''; + if ($objp->country == '-') $objp->country = ''; - $adherentstatic->id=$objp->rowid; - $adherentstatic->lastname=$objp->lastname; - $adherentstatic->firstname=$objp->firstname; + $adherentstatic->id = $objp->rowid; + $adherentstatic->lastname = $objp->lastname; + $adherentstatic->firstname = $objp->firstname; // Format extrafield so they can be parsed in function complete_substitutions_array if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $adherentstatic->array_options = array(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $tmpkey='options_'.$key; + $tmpkey = 'options_'.$key; if (!empty($objp->$tmpkey)) { $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; @@ -115,7 +115,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg } // List of values to scan for a replacement - $substitutionarray = array ( + $substitutionarray = array( '__ID__'=>$objp->rowid, '__LOGIN__'=>$objp->login, '__FIRSTNAME__'=>$objp->firstname, @@ -139,21 +139,21 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg complete_substitutions_array($substitutionarray, $langs, $adherentstatic); // For business cards - if (empty($mode) || $mode=='card' || $mode=='cardlogin') + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); if (is_numeric($foruserid) || $foruserlogin) { $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; - if ($nb <= 0) $nb=1; // Protection to avoid empty page + if ($nb <= 0) $nb = 1; // Protection to avoid empty page - for($j=0;$j<$nb;$j++) + for ($j = 0; $j < $nb; $j++) { - $arrayofmembers[]=array( + $arrayofmembers[] = array( 'textleft'=>$textleft, 'textheader'=>$textheader, 'textfooter'=>$textfooter, @@ -165,7 +165,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg } else { - $arrayofmembers[]=array( + $arrayofmembers[] = array( 'textleft'=>$textleft, 'textheader'=>$textheader, 'textfooter'=>$textfooter, @@ -179,13 +179,13 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg // For labels if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; - $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); - $textheader=''; - $textfooter=''; - $textright=''; + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; + $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader = ''; + $textfooter = ''; + $textright = ''; - $arrayofmembers[]=array('textleft'=>$textleft, + $arrayofmembers[] = array('textleft'=>$textleft, 'textheader'=>$textheader, 'textfooter'=>$textfooter, 'textright'=>$textright, @@ -197,29 +197,29 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg } // Build and output PDF - if (empty($mode) || $mode=='card' || $mode=='cardlogin') + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - if (! count($arrayofmembers)) + if (!count($arrayofmembers)) { - $mesg=$langs->trans("ErrorRecordNotFound"); + $mesg = $langs->trans("ErrorRecordNotFound"); } if (empty($model) || $model == '-1') { - $mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); } - if (! $mesg) $result=members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); + if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); } elseif ($mode == 'label') { - if (! count($arrayofmembers)) + if (!count($arrayofmembers)) { - $mesg=$langs->trans("ErrorRecordNotFound"); + $mesg = $langs->trans("ErrorRecordNotFound"); } if (empty($modellabel) || $modellabel == '-1') { - $mesg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); } - if (! $mesg) $result=doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); + if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); } if ($result <= 0) @@ -232,7 +232,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg dol_print_error($db); } - if (! $mesg) + if (!$mesg) { $db->close(); exit; @@ -244,7 +244,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("MembersCards")); @@ -257,40 +257,40 @@ dol_htmloutput_errors($mesg); print '
'; -print img_picto('', 'puce').' '.$langs->trans("DocForAllMembersCards", ($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' '; +print img_picto('', 'puce').' '.$langs->trans("DocForAllMembersCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' '; print ''; -print ''; +print ''; print ''; print ''; print ''; print $langs->trans("DescADHERENT_CARD_TYPE").' '; // List of possible labels (defined into $_Avery_Labels variable set into 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']; } asort($arrayoflabels); -print $form->selectarray('model', $arrayoflabels, (GETPOST('model')?GETPOST('model'):$conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'; print ''; print '

'; -print img_picto('', 'puce').' '.$langs->trans("DocForOneMemberCards", ($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' '; +print img_picto('', 'puce').' '.$langs->trans("DocForOneMemberCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' '; print ''; -print ''; +print ''; print ''; print ''; print $langs->trans("DescADHERENT_CARD_TYPE").' '; // List of possible labels (defined into $_Avery_Labels variable set into 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']; } asort($arrayoflabels); -print $form->selectarray('model', $arrayoflabels, (GETPOST('model')?GETPOST('model'):$conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'.$langs->trans("Login").': '; print '
'; print ''; @@ -299,18 +299,18 @@ print '

'; print img_picto('', 'puce').' '.$langs->trans("DocForLabels", $conf->global->ADHERENT_ETIQUETTE_TYPE).' '; print ''; -print ''; +print ''; print ''; print ''; print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' '; // List of possible labels (defined into $_Avery_Labels variable set into 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']; } asort($arrayoflabels); -print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel') ?GETPOST('modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'; print ''; diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 1357e4a3b4b..bdb174cc0bd 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -23,8 +23,8 @@ * \brief Fichier de la classe de gestion des stats des adhérents */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; /** @@ -61,17 +61,17 @@ class AdherentStats extends Stats $this->socid = $socid; $this->userid = $userid; - $object=new Subscription($this->db); + $object = new Subscription($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - $this->from.= ", ".MAIN_DB_PREFIX."adherent as m"; + $this->from .= ", ".MAIN_DB_PREFIX."adherent as m"; - $this->field='subscription'; + $this->field = 'subscription'; - $this->where.= " m.statut != 0"; - $this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; + $this->where .= " m.statut != 0"; + $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if($this->memberid) + if ($this->memberid) { $this->where .= " AND m.rowid = ".$this->memberid; } @@ -91,12 +91,12 @@ class AdherentStats extends Stats global $user; $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByMonth($year, $sql, $format); } @@ -111,11 +111,11 @@ class AdherentStats extends Stats global $user; $sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -132,12 +132,12 @@ class AdherentStats extends Stats global $user; $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAmountByMonth($year, $sql, $format); } @@ -153,12 +153,12 @@ class AdherentStats extends Stats global $user; $sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE date_format(p.dateadh,'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -174,11 +174,11 @@ class AdherentStats extends Stats global $user; $sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 3a17f5c7c28..bbc03c3387f 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -59,17 +59,17 @@ class Members extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -98,50 +98,50 @@ class Members extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $sql = "SELECT t.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')'; if (!empty($typeid)) { - $sql.= ' AND t.fk_adherent_type='.$typeid; + $sql .= ' AND t.fk_adherent_type='.$typeid; } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) { $obj = $db->fetch_object($result); $member = new Adherent($this->db); - if($member->fetch($obj->rowid)) { + if ($member->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($member); } $i++; @@ -150,7 +150,7 @@ class Members extends DolibarrApi else { throw new RestException(503, 'Error when retrieve member list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No member found'); } @@ -165,14 +165,14 @@ class Members extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); $member = new Adherent($this->db); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $member->$field = $value; } if ($member->create(DolibarrApiAccess::$user) < 0) { @@ -190,21 +190,21 @@ class Members extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('member', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; // Process the status separately because it must be updated using // the validate() and resiliate() methods of the class Adherent. @@ -245,20 +245,20 @@ class Members extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->adherent->supprimer) { + if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if( ! DolibarrApi::_checkAccessToResource('member', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $member->delete($member->id, DolibarrApiAccess::$user)) { + if (!$member->delete($member->id, DolibarrApiAccess::$user)) { throw new RestException(401, 'error when deleting member'); } @@ -334,13 +334,13 @@ class Members extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } @@ -365,13 +365,13 @@ class Members extends DolibarrApi */ public function createSubscription($id, $start_date, $end_date, $amount, $label = '') { - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } @@ -393,7 +393,7 @@ class Members extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 987e3e2ea87..98cb25b7fc3 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -55,17 +55,17 @@ class MembersTypes extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $membertype = new AdherentType($this->db); $result = $membertype->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member type not found'); } - if( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -92,40 +92,40 @@ class MembersTypes extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $sql = "SELECT t.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')'; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')'; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -141,7 +141,7 @@ class MembersTypes extends DolibarrApi else { throw new RestException(503, 'Error when retrieve member type list : '.$db->lasterror()); } - if ( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No member type found'); } @@ -156,14 +156,14 @@ class MembersTypes extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); $membertype = new AdherentType($this->db); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $membertype->$field = $value; } if ($membertype->create(DolibarrApiAccess::$user) < 0) { @@ -181,21 +181,21 @@ class MembersTypes extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); } $membertype = new AdherentType($this->db); $result = $membertype->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member type not found'); } - if( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; // Process the status separately because it must be updated using // the validate() and resiliate() methods of the class AdherentType. @@ -222,20 +222,20 @@ class MembersTypes extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); } $membertype = new AdherentType($this->db); $result = $membertype->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'member type not found'); } - if ( ! DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $membertype->delete()) { + if (!$membertype->delete()) { throw new RestException(401, 'error when deleting member type'); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 101ed822466..c9804e5d802 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -58,13 +58,13 @@ class Subscriptions extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { throw new RestException(401); } $subscription = new Subscription($this->db); $result = $subscription->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Subscription not found'); } @@ -91,45 +91,45 @@ class Subscriptions extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { throw new RestException(401); } $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."subscription as t"; - $sql.= ' WHERE 1 = 1'; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; + $sql .= ' WHERE 1 = 1'; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); while ($i < min($limit, $num)) { $obj = $db->fetch_object($result); $subscription = new Subscription($this->db); - if($subscription->fetch($obj->rowid)) { + if ($subscription->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($subscription); } $i++; @@ -138,7 +138,7 @@ class Subscriptions extends DolibarrApi else { throw new RestException(503, 'Error when retrieve subscription list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No Subscription found'); } @@ -153,14 +153,14 @@ class Subscriptions extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); $subscription = new Subscription($this->db); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $subscription->$field = $value; } if ($subscription->create(DolibarrApiAccess::$user) < 0) { @@ -178,17 +178,17 @@ class Subscriptions extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $subscription = new Subscription($this->db); $result = $subscription->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Subscription not found'); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $subscription->$field = $value; } @@ -212,16 +212,16 @@ class Subscriptions extends DolibarrApi public function delete($id) { // The right to delete a subscription comes with the right to create one. - if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); } $subscription = new Subscription($this->db); $result = $subscription->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Subscription not found'); } - if (! $subscription->delete(DolibarrApiAccess::$user)) { + if (!$subscription->delete(DolibarrApiAccess::$user)) { throw new RestException(401, 'error when deleting subscription'); } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 99a0c113e9a..e512e1152bb 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -35,12 +35,12 @@ class Subscription extends CommonObject /** * @var string ID to identify managed object */ - public $element='subscription'; + public $element = 'subscription'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='subscription'; + public $table_element = 'subscription'; /** * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table @@ -50,7 +50,7 @@ class Subscription extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='payment'; + public $picto = 'payment'; /** * Date creation record (datec) @@ -93,7 +93,7 @@ class Subscription extends CommonObject */ public $fk_bank; - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), @@ -133,12 +133,12 @@ class Subscription extends CommonObject $error = 0; - $now=dol_now(); + $now = dol_now(); // Check parameters if ($this->datef <= $this->dateh) { - $this->error=$langs->trans("ErrorBadValueForDate"); + $this->error = $langs->trans("ErrorBadValueForDate"); return -1; } if (empty($this->datec)) $this->datec = $now; @@ -149,37 +149,37 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); if ($this->fk_type == null) { // If type not defined, we use the type of member - $type=$member->typeid; + $type = $member->typeid; } else { - $type=$this->fk_type; + $type = $this->fk_type; } - $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->dateh)."',"; - $sql.= " '".$this->db->idate($this->datef)."',"; - $sql.= " ".$this->amount.","; - $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; + $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->dateh)."',"; + $sql .= " '".$this->db->idate($this->datef)."',"; + $sql .= " ".$this->amount.","; + $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror(); } - if (! $error) + if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->fk_type = $type; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { $this->context = array('member'=>$member); // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -203,16 +203,16 @@ class Subscription extends CommonObject */ public function fetch($rowid) { - $sql ="SELECT rowid, fk_type, fk_adherent, datec,"; - $sql.=" tms,"; - $sql.=" dateadh as dateh,"; - $sql.=" datef,"; - $sql.=" subscription, note, fk_bank"; - $sql.=" FROM ".MAIN_DB_PREFIX."subscription"; - $sql.=" WHERE rowid=".$rowid; + $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; + $sql .= " tms,"; + $sql .= " dateadh as dateh,"; + $sql .= " datef,"; + $sql .= " subscription, note, fk_bank"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -240,7 +240,7 @@ class Subscription extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -275,14 +275,14 @@ class Subscription extends CommonObject if ($resql) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { $this->context = array('member'=>$member); // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -290,7 +290,7 @@ class Subscription extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } // Commit or rollback @@ -318,39 +318,39 @@ class Subscription extends CommonObject if ($this->fk_bank > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline=new AccountLine($this->db); - $result=$accountline->fetch($this->fk_bank); + $accountline = new AccountLine($this->db); + $result = $accountline->fetch($this->fk_bank); } $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail // End call triggers } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->affected_rows($resql); + $num = $this->db->affected_rows($resql); if ($num) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) { - $result=$accountline->delete($user); // Return false if refused because line is conciliated + $result = $accountline->delete($user); // Return false if refused because line is conciliated if ($result > 0) { $this->db->commit(); @@ -358,7 +358,7 @@ class Subscription extends CommonObject } else { - $this->error=$accountline->error; + $this->error = $accountline->error; $this->db->rollback(); return -1; } @@ -378,7 +378,7 @@ class Subscription extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } @@ -407,29 +407,29 @@ class Subscription extends CommonObject { global $langs; - $result=''; + $result = ''; $langs->load("members"); - $label=$langs->trans("ShowSubscription").': '.$this->ref; + $label = $langs->trans("ShowSubscription").': '.$this->ref; $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = ''; $linkend = ''; - $picto='payment'; + $picto = 'payment'; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -471,11 +471,11 @@ class Subscription extends CommonObject public function info($id) { $sql = 'SELECT c.rowid, c.datec,'; - $sql.= ' c.tms as datem'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql.= ' WHERE c.rowid = '.$id; + $sql .= ' c.tms as datem'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index ca74d9bcbda..cc3e06207be 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -34,45 +34,45 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","members","other")); +$langs->loadLangs(array("companies", "members", "other")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); // Security check -$result=restrictedArea($user, 'adherent', $id); +$result = restrictedArea($user, 'adherent', $id); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page ; +$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"; $form = new Form($db); -$object=new Adherent($db); -$membert=new AdherentType($db); -$result=$object->fetch($id); +$object = new Adherent($db); +$membert = new AdherentType($db); +$result = $object->fetch($id); if ($result < 0) { dol_print_error($db); exit; } -$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); +$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member'); /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -81,24 +81,24 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title=$langs->trans("Member") . " - " . $langs->trans("Documents"); -$helpurl="EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; +$title = $langs->trans("Member")." - ".$langs->trans("Documents"); +$helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; llxHeader("", $title, $helpurl); if ($id > 0) { - $result=$membert->fetch($object->typeid); + $result = $membert->fetch($object->typeid); if ($result > 0) { // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); @@ -154,8 +154,8 @@ if ($id > 0) $modulepart = 'member'; $permission = $user->rights->adherent->creer; $permtoedit = $user->rights->adherent->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; print "

"; } else diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index 84fc6bc9824..b7aa8da5d14 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -27,7 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // Security check -if (! $user->rights->adherent->export) accessforbidden(); +if (!$user->rights->adherent->export) accessforbidden(); /* @@ -36,30 +36,30 @@ if (! $user->rights->adherent->export) accessforbidden(); llxHeader(); -$now=dol_now(); +$now = dol_now(); -if (empty($sortorder)) { $sortorder="ASC"; } -if (empty($sortfield)) { $sortfield="d.login"; } -if (! isset($statut)) +if (empty($sortorder)) { $sortorder = "ASC"; } +if (empty($sortfield)) { $sortfield = "d.login"; } +if (!isset($statut)) { $statut = 1; } -if (! isset($cotis)) +if (!isset($cotis)) { // by default, members must be up to date of subscription - $cotis=1; + $cotis = 1; } $sql = "SELECT d.login, d.pass, d.datefin"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d "; $sql .= " WHERE d.statut = ".$statut; -if ($cotis==1) +if ($cotis == 1) { $sql .= " AND datefin > '".$db->idate($now)."'"; } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); //$sql.=$db->plimit($conf->liste_limit, $offset); $resql = $db->query($sql); @@ -74,7 +74,7 @@ if ($resql) while ($i < $num) { $objp = $db->fetch_object($result); - $htpass=crypt($objp->pass, makesalt()); + $htpass = crypt($objp->pass, makesalt()); print $objp->login.":".$htpass."
\n"; $i++; } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index ed78245332b..44fcb397ddc 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -48,28 +48,28 @@ $result = restrictedArea($user, 'adherent'); llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -$staticmember=new Adherent($db); -$statictype=new AdherentType($db); -$subscriptionstatic=new Subscription($db); +$staticmember = new Adherent($db); +$statictype = new AdherentType($db); +$subscriptionstatic = new Subscription($db); print load_fiche_titre($langs->trans("MembersArea"), '', 'members'); -$Adherents=array(); -$AdherentsAValider=array(); -$MemberUpToDate=array(); -$AdherentsResilies=array(); +$Adherents = array(); +$AdherentsAValider = array(); +$MemberUpToDate = array(); +$AdherentsResilies = array(); -$AdherentType=array(); +$AdherentType = array(); // Type of membership $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; -$sql.= " d.statut, count(d.rowid) as somme"; -$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; -$sql.= " ON t.rowid = d.fk_adherent_type"; -$sql.= " AND d.entity IN (".getEntity('adherent').")"; -$sql.= " WHERE t.entity IN (".getEntity('member_type').")"; -$sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; +$sql .= " d.statut, count(d.rowid) as somme"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; +$sql .= " ON t.rowid = d.fk_adherent_type"; +$sql .= " AND d.entity IN (".getEntity('adherent').")"; +$sql .= " WHERE t.entity IN (".getEntity('member_type').")"; +$sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members per type", LOG_DEBUG); $result = $db->query($sql); @@ -81,32 +81,32 @@ if ($result) { $objp = $db->fetch_object($result); - $adhtype=new AdherentType($db); - $adhtype->id=$objp->rowid; - $adhtype->subscription=$objp->subscription; - $adhtype->label=$objp->label; - $AdherentType[$objp->rowid]=$adhtype; + $adhtype = new AdherentType($db); + $adhtype->id = $objp->rowid; + $adhtype->subscription = $objp->subscription; + $adhtype->label = $objp->label; + $AdherentType[$objp->rowid] = $adhtype; - if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; } - if ($objp->statut == 1) { $MembersValidated[$objp->rowid]=$objp->somme; } - if ($objp->statut == 0) { $MembersResiliated[$objp->rowid]=$objp->somme; } + if ($objp->statut == -1) { $MemberToValidate[$objp->rowid] = $objp->somme; } + if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; } + if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; } $i++; } $db->free($result); } -$now=dol_now(); +$now = dol_now(); // Members up to date list // current rule: uptodate = the end date is in future whatever is type // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) $sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql.= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; -$sql.= " AND t.rowid = d.fk_adherent_type"; -$sql.= " GROUP BY d.fk_adherent_type"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; +$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; +$sql .= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; +$sql .= " AND t.rowid = d.fk_adherent_type"; +$sql .= " GROUP BY d.fk_adherent_type"; dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); $result = $db->query($sql); @@ -220,15 +220,15 @@ if ($conf->use_javascript_ajax) print '
'; // List of subscription by year -$Total=array(); -$Number=array(); -$tot=0; -$numb=0; +$Total = array(); +$Number = array(); +$tot = 0; +$numb = 0; $sql = "SELECT c.subscription, c.dateadh as dateh"; -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql.= " AND d.rowid = c.fk_adherent"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; +$sql .= " AND d.rowid = c.fk_adherent"; $result = $db->query($sql); @@ -323,26 +323,26 @@ if ($resql) { $obj = $db->fetch_object($resql); print ''; - $staticmember->id=$obj->rowid; - $staticmember->lastname=$obj->lastname; - $staticmember->firstname=$obj->firstname; - if (! empty($obj->fk_soc)) + $staticmember->id = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; + if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); - $staticmember->name=$staticmember->thirdparty->name; + $staticmember->name = $staticmember->thirdparty->name; } else { - $staticmember->name=$obj->company; + $staticmember->name = $obj->company; } - $staticmember->ref=$staticmember->getFullName($langs); - $statictype->id=$obj->typeid; - $statictype->label=$obj->label; + $staticmember->ref = $staticmember->getFullName($langs); + $statictype->id = $obj->typeid; + $statictype->label = $obj->label; print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; } diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 99326241485..6a49f99fbf4 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -30,21 +30,21 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","members","ldap","admin")); +$langs->loadLangs(array("companies", "members", "ldap", "admin")); $rowid = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); // Protection -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; } $object = new Adherent($db); -$result=$object->fetch($rowid); -if (! $result) +$result = $object->fetch($rowid); +if (!$result) { dol_print_error($db, "Failed to get adherent: ".$object->error); exit; @@ -57,16 +57,16 @@ if (! $result) if ($action == 'dolibarr2ldap') { - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); - $olddn=$dn; // We can say that old dn = dn as we force synchro + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); + $olddn = $dn; // We can say that old dn = dn as we force synchro - $result=$ldap->update($dn, $info, $user, $olddn); + $result = $ldap->update($dn, $info, $user, $olddn); } if ($result >= 0) { @@ -104,7 +104,7 @@ print '
'.$staticmember->getNomUrl(1, 32).''.$statictype->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).''.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).'
'; print ''; // If there is a link to password not crypted, we show value in database here so we can compare because it is shown nowhere else -if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) +if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) { print ''; print ''; @@ -142,14 +142,14 @@ dol_fiche_end(); print '
'; -if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { print ''; } print "
\n"; -if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "
\n"; +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "
\n"; @@ -164,12 +164,12 @@ print ''; print ''; // Lecture LDAP -$ldap=new Ldap(); -$result=$ldap->connect_bind(); +$ldap = new Ldap(); +$result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info, 1); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; if (empty($dn)) @@ -184,15 +184,15 @@ if ($result > 0) //print_r($records); // Show tree - if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (! is_array($records)) + if (!is_array($records)) { print ''; } else { - $result=show_ldap_content($records, 0, $records['count'], true); + $result = show_ldap_content($records, 0, $records['count'], true); } } else diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 7e8175793fd..ee72c920e2f 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -29,23 +29,23 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","members","bills")); +$langs->loadLangs(array("companies", "members", "bills")); -$action=GETPOST('action', 'alpha'); -$id=GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$id = GETPOST('id', 'int'); // Security check -$result=restrictedArea($user, 'adherent', $id); +$result = restrictedArea($user, 'adherent', $id); $object = new Adherent($db); -$result=$object->fetch($id); +$result = $object->fetch($id); if ($result > 0) { $adht = new AdherentType($db); - $result=$adht->fetch($object->typeid); + $result = $adht->fetch($object->typeid); } -$permissionnote=$user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php /* * Actions @@ -58,8 +58,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, /* * View */ -$title=$langs->trans("Member") . " - " . $langs->trans("Note"); -$helpurl="EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; +$title = $langs->trans("Member")." - ".$langs->trans("Note"); +$helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; llxHeader("", $title, $helpurl); $form = new Form($db); @@ -110,8 +110,8 @@ if ($id) print ''; - $cssclass='titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + $cssclass = 'titlefield'; + $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index e75e1a61e70..abc9b6d80a7 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -29,7 +29,7 @@ $graphwidth = 700; $mapratio = 0.5; $graphheight = round($graphwidth * $mapratio); -$mode=GETPOST('mode')?GETPOST('mode'):''; +$mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check @@ -38,57 +38,57 @@ if ($user->socid > 0) $action = ''; $socid = $user->socid; } -$result=restrictedArea($user, 'adherent', '', '', 'cotisation'); +$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $year = strftime("%Y", time()); -$startyear=$year-2; -$endyear=$year; +$startyear = $year - 2; +$endyear = $year; // Load translation files required by the page -$langs->loadLangs(array("companies","members")); +$langs->loadLangs(array("companies", "members")); /* * View */ -$memberstatic=new Adherent($db); +$memberstatic = new Adherent($db); llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, array('https://www.google.com/jsapi')); -$title=$langs->trans("MembersStatisticsByProperties"); +$title = $langs->trans("MembersStatisticsByProperties"); print load_fiche_titre($title, ''); dol_mkdir($dir); -$tab='byproperties'; +$tab = 'byproperties'; $data = array(); -$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code"; -$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; -$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; -$sql.=" WHERE d.entity IN (".getEntity('adherent').")"; -$sql.=" AND d.statut = 1"; -$sql.=" GROUP BY d.morphy"; +$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; +$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; +$sql .= " AND d.statut = 1"; +$sql .= " GROUP BY d.morphy"; -$foundphy=$foundmor=0; +$foundphy = $foundmor = 0; // Define $data array dol_syslog("Count member", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); - $i=0; + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($obj->code == 'phy') $foundphy++; if ($obj->code == 'mor') $foundmor++; - $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); + $data[] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); $i++; } @@ -106,7 +106,7 @@ dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'use // Print title -if (! count($data)) +if (!count($data)) { print $langs->trans("NoValidatedMemberYet").'
'; print '
'; @@ -125,8 +125,8 @@ print ''; print ''; print ''; -if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); -if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); +if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); +if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); foreach ($data as $val) { diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 956a71112cb..683ae558d28 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -26,11 +26,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -$graphwidth=DolGraph::getDefaultGraphSizeForStats('width', 700); +$graphwidth = DolGraph::getDefaultGraphSizeForStats('width', 700); $mapratio = 0.5; $graphheight = round($graphwidth * $mapratio); -$mode=GETPOST('mode')?GETPOST('mode'):''; +$mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check @@ -39,28 +39,28 @@ if ($user->socid > 0) $action = ''; $socid = $user->socid; } -$result=restrictedArea($user, 'adherent', '', '', 'cotisation'); +$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $year = strftime("%Y", time()); -$startyear=$year-2; -$endyear=$year; +$startyear = $year - 2; +$endyear = $year; // Load translation files required by the page -$langs->loadLangs(array("companies","members")); +$langs->loadLangs(array("companies", "members")); /* * View */ -$arrayjs=array('https://www.google.com/jsapi'); -if (! empty($conf->dol_use_jmobile)) $arrayjs=array(); +$arrayjs = array('https://www.google.com/jsapi'); +if (!empty($conf->dol_use_jmobile)) $arrayjs = array(); -$title=$langs->trans("Statistics"); -if ($mode == 'memberbycountry') $title=$langs->trans("MembersStatisticsByCountries"); -if ($mode == 'memberbystate') $title=$langs->trans("MembersStatisticsByState"); -if ($mode == 'memberbytown') $title=$langs->trans("MembersStatisticsByTown"); -if ($mode == 'memberbyregion') $title=$langs->trans("MembersStatisticsByRegion"); +$title = $langs->trans("Statistics"); +if ($mode == 'memberbycountry') $title = $langs->trans("MembersStatisticsByCountries"); +if ($mode == 'memberbystate') $title = $langs->trans("MembersStatisticsByState"); +if ($mode == 'memberbytown') $title = $langs->trans("MembersStatisticsByTown"); +if ($mode == 'memberbyregion') $title = $langs->trans("MembersStatisticsByRegion"); llxHeader('', $title, '', '', 0, 0, $arrayjs); @@ -73,92 +73,92 @@ if ($mode) // Define sql if ($mode == 'memberbycountry') { - $label=$langs->trans("Country"); - $tab='statscountry'; + $label = $langs->trans("Country"); + $tab = 'statscountry'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; - $sql.=" AND d.statut = 1"; - $sql.=" GROUP BY c.label, c.code"; + $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut = 1"; + $sql .= " GROUP BY c.label, c.code"; //print $sql; } if ($mode == 'memberbystate') { - $label=$langs->trans("Country"); - $label2=$langs->trans("State"); - $tab='statsstate'; + $label = $langs->trans("Country"); + $label2 = $langs->trans("State"); + $tab = 'statsstate'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; - $sql.=" AND d.statut = 1"; - $sql.=" GROUP BY co.label, co.code, c.nom"; + $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut = 1"; + $sql .= " GROUP BY co.label, co.code, c.nom"; //print $sql; } if ($mode == 'memberbyregion') // { - $label=$langs->trans("Country"); - $label2=$langs->trans("Region"); //département - $tab='statsregion'; //onglet + $label = $langs->trans("Country"); + $label2 = $langs->trans("Region"); //département + $tab = 'statsregion'; //onglet $data = array(); //tableau de donnée - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; - $sql.=" AND d.statut = 1"; - $sql.=" GROUP BY co.label, co.code, r.nom"; //+ + $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut = 1"; + $sql .= " GROUP BY co.label, co.code, r.nom"; //+ //print $sql; } if ($mode == 'memberbytown') { - $label=$langs->trans("Country"); - $label2=$langs->trans("Town"); - $tab='statstown'; + $label = $langs->trans("Country"); + $label2 = $langs->trans("Town"); + $tab = 'statstown'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; - $sql.=" AND d.statut = 1"; - $sql.=" GROUP BY c.label, c.code, d.town"; + $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut = 1"; + $sql .= " GROUP BY c.label, c.code, d.town"; //print $sql; } - $langsen=new Translate('', $conf); + $langsen = new Translate('', $conf); $langsen->setDefaultLang('en_US'); $langsen->load("dict"); //print $langsen->trans("Country"."FI");exit; // Define $data array dol_syslog("Count member", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); - $i=0; + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($mode == 'memberbycountry') { - $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), @@ -167,10 +167,10 @@ if ($mode) } if ($mode == 'memberbyregion') //+ { - $data[]=array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), + $data[] = array( + 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) @@ -178,9 +178,9 @@ if ($mode) } if ($mode == 'memberbystate') { - $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) @@ -188,9 +188,9 @@ if ($mode) } if ($mode == 'memberbytown') { - $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) @@ -214,7 +214,7 @@ dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title -if ($mode && ! count($data)) +if ($mode && !count($data)) { print $langs->trans("NoValidatedMemberYet").'
'; print '
'; @@ -224,7 +224,7 @@ else if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'
'; elseif ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'
'; elseif ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'
';//+ + elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'
'; //+ else { print $langs->trans("MembersStatisticsDesc").'
'; @@ -234,8 +234,8 @@ else print ''.$langs->trans("MembersStatisticsByState").'
'; print '
'; print ''.$langs->trans("MembersStatisticsByTown").'
'; - print '
';//+ - print ''.$langs->trans("MembersStatisticsByRegion").'
';//+ + print '
'; //+ + print ''.$langs->trans("MembersStatisticsByRegion").'
'; //+ } print '
'; } @@ -260,16 +260,16 @@ if (count($arrayjs) && $mode == 'memberbycountry') print "\tdata.addColumn('number', 'Number');\n"; // loop and dump - $i=0; - foreach($data as $val) + $i = 0; + foreach ($data as $val) { - $valcountry=strtoupper($val['code']); // Should be ISO-3166 code (faster) + $valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster) //$valcountry=ucfirst($val['label_en']); if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels) print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n"; print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n"; // Google's Geomap only supports up to 400 entries - if ($i >= 400){ break; } + if ($i >= 400) { break; } $i++; } diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 10eca32ac13..cb0e6a463e4 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -28,11 +28,11 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; -$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; // Security check if ($user->socid > 0) @@ -40,28 +40,28 @@ if ($user->socid > 0) $action = ''; $socid = $user->socid; } -$result=restrictedArea($user, 'adherent', '', '', 'cotisation'); +$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $year = strftime("%Y", time()); -$startyear=$year-2; -$endyear=$year; +$startyear = $year - 2; +$endyear = $year; // Load translation files required by the page -$langs->loadLangs(array("companies","members")); +$langs->loadLangs(array("companies", "members")); /* * View */ -$form=new Form($db); +$form = new Form($db); $title = $langs->trans("SubscriptionsStatistics"); llxHeader('', $title); print load_fiche_titre($title, '', 'members'); -$dir=$conf->adherent->dir_temp; +$dir = $conf->adherent->dir_temp; dol_mkdir($dir); @@ -79,13 +79,13 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px1->SetData($data); - $i=$startyear; + $i = $startyear; while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px1->SetLegend($legend); @@ -96,7 +96,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("NbOfSubscriptions")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NbOfSubscriptions")); $px1->draw($filenamenb, $fileurlnb); @@ -112,13 +112,13 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); -if (! $mesg) +if (!$mesg) { $px2->SetData($data); - $i=$startyear; + $i = $startyear; while ($i <= $endyear) { - $legend[]=$i; + $legend[] = $i; $i++; } $px2->SetLegend($legend); @@ -129,7 +129,7 @@ if (! $mesg) $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); $px2->SetShading(3); $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfSubscriptions")); $px2->draw($filenameamount, $fileurlamount); @@ -174,11 +174,11 @@ print ''; print ''; print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while ($oldyear > $year+1) + while ($oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -202,7 +202,7 @@ foreach ($data as $val) print ''; print ''; print ''; - $oldyear=$year; + $oldyear = $year; } print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("LDAPFieldPasswordNotCrypted").''.$object->pass.''.$langs->trans("Value").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'.price(price2num($val['total'], 'MT'), 1).''.price(price2num($val['avg'], 'MT'), 1).'
'; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 12301b272a6..47866fc8981 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -81,33 +81,33 @@ if ($rowid) $result = $object->fetch($rowid); // Define variables to know what current user can do on users - $canadduser=($user->admin || $user->rights->user->user->creer); + $canadduser = ($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $user is the user editing, $object->user_id is the user's id linked to the edited member - $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer) ); - $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password) ); + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer)); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password)); } } // Define variables to know what current user can do on members -$canaddmember=$user->rights->adherent->creer; +$canaddmember = $user->rights->adherent->creer; // Define variables to know what current user can do on properties of a member if ($rowid) { - $caneditfieldmember=$user->rights->adherent->creer; + $caneditfieldmember = $user->rights->adherent->creer; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscription')); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); /* diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index f3d9fc5790c..78b3fd4384b 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","members","bills","users")); +$langs->loadLangs(array("companies", "members", "bills", "users")); if (!$user->rights->adherent->lire) accessforbidden(); -$rowid=GETPOST("rowid", 'int'); +$rowid = GETPOST("rowid", 'int'); diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 26850c72b84..4c68b82784f 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -71,21 +71,21 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad $current_lang = $langs->getDefaultLang(); // update of object - if ( $_POST["forcelangprod"] == $current_lang ) + if ($_POST["forcelangprod"] == $current_lang) { $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->description = dol_htmlcleanlastbr($_POST["desc"]); $object->other = dol_htmlcleanlastbr($_POST["other"]); } else { $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); } // backup into database - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index a1b2e9db91c..7a436c5a363 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -28,27 +28,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -$action=GETPOST('action', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminaccoutant'; // To manage different context of search +$action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$error=0; +$error = 0; /* * Actions */ -$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 ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) -|| ($action == 'updateedit') ) +if (($action == 'update' && !GETPOST("cancel", 'alpha')) +|| ($action == 'updateedit')) { dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity); @@ -64,7 +64,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity); - if ($action != 'updateedit' && ! $error) + if ($action != 'updateedit' && !$error) { header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -75,7 +75,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) * View */ -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("CompanyFoundation"), $help_url); print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); @@ -84,11 +84,11 @@ $head = company_admin_prepare_head(); dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company'); -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); -$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; print ''.$langs->trans("AccountantDesc")."
\n"; print "
\n"; @@ -114,17 +114,17 @@ print ''.$langs->trans( // Name print ''; -print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; +print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; // Address print ''; -print ''."\n"; +print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; // Country print ''; @@ -139,28 +139,28 @@ print ''."\n"; print ''; print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; print ''; print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; print ''; print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; // Web print ''; print img_picto('', 'globe', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; // Code print ''; -print ''."\n"; +print ''."\n"; // Note print ''; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index b01f96019b5..b6231a45a10 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -172,7 +172,7 @@ if (!empty($triggers)) // If 'element' value is myobject@mymodule instead of mymodule $tmparray = explode('@', $module); - if (! empty($tmparray[1])) { + if (!empty($tmparray[1])) { $module = $tmparray[1]; } diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index b4d71415e05..a0197f70274 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='actioncomm'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -64,15 +64,15 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Agenda"); +$textobject = $langs->transnoentitiesnoconv("Agenda"); -$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action'); @@ -109,7 +109,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 9eddccd0ba9..77113ff1e13 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -38,14 +38,14 @@ if (!$user->admin) accessforbidden(); $langs->loadLangs(array('agenda', 'admin', 'other')); $def = array(); -$actiontest=GETPOST('test', 'alpha'); -$actionsave=GETPOST('save', 'alpha'); +$actiontest = GETPOST('test', 'alpha'); +$actionsave = GETPOST('save', 'alpha'); -if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=$conf->global->AGENDA_EXT_NB; +if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; +$MAXAGENDA = $conf->global->AGENDA_EXT_NB; // List of available colors -$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); +$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5'); /* @@ -56,23 +56,23 @@ if ($actionsave) { $db->begin(); - $disableext=GETPOST('AGENDA_DISABLE_EXT', 'alpha'); - $res=dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); + $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); + $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); - $i=1; $errorsaved=0; - $error=0; + $i = 1; $errorsaved = 0; + $error = 0; // Save agendas while ($i <= $MAXAGENDA) { - $name=trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha')); - $src=trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha')); - $offsettz=trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha')); - $color=trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha')); - if ($color=='-1') $color=''; - $enabled=trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha')); + $name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha')); + $src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha')); + $offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha')); + $color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha')); + if ($color == '-1') $color = ''; + $enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha')); - if (! empty($src) && ! dol_is_url($src)) + if (!empty($src) && !dol_is_url($src)) { setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); $error++; @@ -81,29 +81,29 @@ if ($actionsave) } //print '-name='.$name.'-color='.$color; - $res=dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; $i++; } // Save nb of agenda - if (! $error) + if (!$error) { - $res=dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; - $MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB; + $res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; + $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -119,24 +119,24 @@ if ($actionsave) * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); -$formother=new FormOther($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formother = new FormOther($db); -$arrayofjs=array(); -$arrayofcss=array(); +$arrayofjs = array(); +$arrayofcss = array(); -$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp, '', 0, 0, $arrayofjs, $arrayofcss); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); print '
'; print ''; print ''; -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); @@ -144,8 +144,8 @@ print ''.$langs->trans("AgendaExtSitesDesc")."\n"; -$selectedvalue=$conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; +$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; +if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; print ""; @@ -199,30 +199,30 @@ print "'; print ""; -$i=1; +$i = 1; while ($i <= $MAXAGENDA) { - $key=$i; - $name='AGENDA_EXT_NAME'.$key; - $src='AGENDA_EXT_SRC'.$key; - $offsettz='AGENDA_EXT_OFFSETTZ'.$key; - $color='AGENDA_EXT_COLOR'.$key; - $enabled='AGENDA_EXT_ENABLED'.$key; + $key = $i; + $name = 'AGENDA_EXT_NAME'.$key; + $src = 'AGENDA_EXT_SRC'.$key; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$key; + $color = 'AGENDA_EXT_COLOR'.$key; + $enabled = 'AGENDA_EXT_ENABLED'.$key; print ''; // Nb print '"; // Name - print ''; + print ''; // URL - print ''; + print ''; // Offset TZ - print ''; + print ''; // Color (Possible colors are limited by Google) print ''; print ""; $i++; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 4960f044065..10bfa13d1ce 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -324,7 +324,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } print ''; -print ''; +print ''; print ''; print '
".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFix print ''.$langs->trans("Color").'
'.$langs->trans("AgendaExtNb", $key)."'; //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); - print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key)?GETPOST("AGENDA_EXT_COLOR".$key):$conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); + print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : $conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); print '
'."\n"; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index b641dd74fe2..3d51bd3158c 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -30,7 +30,7 @@ if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array("admin","other","agenda")); +$langs->loadLangs(array("admin", "other", "agenda")); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); @@ -48,8 +48,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; - $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); + $code = $reg[1]; + $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); @@ -63,7 +63,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (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"]); @@ -83,21 +83,21 @@ if ($action == 'set') } elseif ($action == 'specimen') // For orders { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); $commande->initAsSpecimen(); - $commande->thirdparty=$specimenthirdparty; + $commande->thirdparty = $specimenthirdparty; // 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/action/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -166,21 +166,21 @@ elseif ($action == 'setdoc') * View */ -$formactions=new FormActions($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$formactions = new FormActions($db); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader(); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action'); print ''; -print ''; +print ''; print ''; print '
'."\n"; diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index c5cefe48674..e577942ab21 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -89,17 +89,17 @@ elseif ($action == 'update') elseif ($action == 'updateengine') { $sql = "SELECT rowid, coder"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY code"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -109,12 +109,12 @@ elseif ($action == 'updateengine') $code_id = $obj->rowid; $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; - $sqlp.= " SET coder = '" . $coder."'"; - $sqlp.= " WHERE rowid = ". $code_id; - $sqlp.= " AND entity = ".$conf->entity; + $sqlp .= " SET coder = '".$coder."'"; + $sqlp .= " WHERE rowid = ".$code_id; + $sqlp .= " AND entity = ".$conf->entity; - $upsql=$db->query($sqlp); - if (! $upsql) dol_print_error($db); + $upsql = $db->query($sqlp); + if (!$upsql) dol_print_error($db); } $i++; @@ -209,18 +209,18 @@ print '' print "\n"; $sql = "SELECT rowid, code as encoding, libelle as label, coder, example"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; -$sql.= " WHERE entity = ".$conf->entity; -$sql.= " ORDER BY code"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; +$sql .= " WHERE entity = ".$conf->entity; +$sql .= " ORDER BY code"; dol_syslog("admin/barcode.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) + while ($i < $num) { $obj = $db->fetch_object($resql); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 76fc188bc0c..c6ff9e94749 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -473,7 +473,7 @@ print ''; print ''; // Activate FileCache - Developement -if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { +if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { print ''; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index f5f0f6eb752..8b5e7c433bf 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","companies","bills","other","banks")); +$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); if (!$user->admin) accessforbidden(); @@ -51,13 +51,13 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_AD if ($action == 'updateMask') { - $maskconstchequereceipts=GETPOST('maskconstchequereceipts', 'alpha'); - $maskchequereceipts=GETPOST('maskchequereceipts', 'alpha'); + $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); + $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); if ($maskconstchequereceipts) $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -74,13 +74,13 @@ if ($action == 'setmod') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') { - $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_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'); } @@ -94,12 +94,12 @@ if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("BankSetupModule")); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); $head = bank_admin_prepare_head(null); @@ -130,25 +130,25 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { $filebis = $file; - $name = substr($file, 4, dol_strlen($file) -16); + $name = substr($file, 4, dol_strlen($file) - 16); $classname = preg_replace('/\.php$/', '', $file); // For compatibility - if (! is_file($dir.$filebis)) + if (!is_file($dir.$filebis)) { $filebis = $file."/".$file.".modules.php"; $classname = "mod_chequereceipt_".$file; } // Check if there is a filter on country preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; $classname = preg_replace('/\-.*$/', '', $classname); - if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') { // Charging the numbering class require_once $dir.$filebis; @@ -156,13 +156,13 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); // 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()) { print ''."\n"; @@ -188,21 +188,21 @@ foreach ($dirmodels as $reldir) } print ''; - $chequereceipts=new RemiseCheque($db); + $chequereceipts = new RemiseCheque($db); $chequereceipts->initAsSpecimen(); // Example - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $chequereceipts); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $chequereceipts); 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).'
'; } } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) // If module is the one used, we show existing errors { - if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); } print ''; @@ -247,15 +247,15 @@ print ''; print ''; print "\n"; -$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 '\n"; $listofnetworks = array('facebook'=>'facebook', 'twitter'=>'twitter', 'linkedin'=>'linkedin', 'instagram'=>'instagram', 'youtube'=>'youtube', 'github'=>'github'); -foreach($listofnetworks as $networkkey => $networkicon) { +foreach ($listofnetworks as $networkkey => $networkicon) { print ''; print ''; // Limit to superadmin -if (! empty($conf->multicompany->enabled) && !$user->entity) +if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; // Show constants $sql = "SELECT"; -$sql.= " rowid"; -$sql.= ", ".$db->decrypt('name')." as name"; -$sql.= ", ".$db->decrypt('value')." as value"; -$sql.= ", type"; -$sql.= ", note"; -$sql.= ", tms"; -$sql.= ", entity"; -$sql.= " FROM ".MAIN_DB_PREFIX."const"; -$sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; +$sql .= " rowid"; +$sql .= ", ".$db->decrypt('name')." as name"; +$sql .= ", ".$db->decrypt('value')." as value"; +$sql .= ", type"; +$sql .= ", note"; +$sql .= ", tms"; +$sql .= ", entity"; +$sql .= " FROM ".MAIN_DB_PREFIX."const"; +$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; if ((empty($user->entity) || $user->admin) && $debug) {} // to force for superadmin to debug -elseif (! GETPOST('visible') || GETPOST('visible') != 'all') $sql.= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits -if (GETPOST('name')) $sql.=natural_search("name", GETPOST('name')); -$sql.= $db->order($sortfield, $sortorder); +elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits +if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name')); +$sql .= $db->order($sortfield, $sortorder); dol_syslog("Const::listConstant", LOG_DEBUG); $result = $db->query($sql); @@ -291,7 +291,7 @@ if ($result) print ''; // Entity limit to superadmin - if (! empty($conf->multicompany->enabled) && !$user->entity) + if (!empty($conf->multicompany->enabled) && !$user->entity) { print '\n"; diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 9a702f56545..926080cb9b5 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -32,9 +32,9 @@ global $conf; if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array("admin","other")); +$langs->loadLangs(array("admin", "other")); -$error=0; +$error = 0; $action = GETPOST('action', 'aZ09'); @@ -54,7 +54,7 @@ if ($action == 'set') $error++; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -73,14 +73,14 @@ if ($action == 'set') llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup'); //print load_fiche_titre($langs->trans("DebugBar")); -if (! function_exists('mb_check_encoding')) +if (!function_exists('mb_check_encoding')) { $langs->load("errors"); print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error'); @@ -100,7 +100,7 @@ print ''; -print ''; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 1944f140ef3..3ee262b464a 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -134,31 +134,31 @@ $modules = array( $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); -if (! isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { - $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php +if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { + $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php } -if (! isset($conf->global->MAIN_DELAY_TASKS_TODO)) { - $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php +if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) { + $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php } -if (! isset($conf->global->MAIN_DELAY_MEMBERS)) { - $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php +if (!isset($conf->global->MAIN_DELAY_MEMBERS)) { + $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php } -if (! isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) { - $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php +if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) { + $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php } -if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { +if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } -if (! isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) { +if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) { $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7; } -if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { +if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } -if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { +if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } -if (! isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { +if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index b687ec02656..7d12ffca433 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -58,7 +58,7 @@ if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1 if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account if (!$allowed) accessforbidden(); -$acts =array(); $actl =array(); +$acts = array(); $actl = array(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); @@ -77,7 +77,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id', 'int'); -if (! GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. +if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. { $search_country_id = $mysoc->country_id; } @@ -445,7 +445,7 @@ $tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_ $tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled)); $tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled); $tabcond[19] = !empty($conf->societe->enabled); -$tabcond[20]= (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)); +$tabcond[20] = (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)); $tabcond[21] = !empty($conf->propal->enabled); $tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled)); $tabcond[23] = true; diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index c0c611f35f5..251322ea798 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -17,7 +17,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (! class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors. +if (!class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors. { include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; } diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 66fa695c5b9..0c348b25f60 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); /* @@ -36,7 +36,7 @@ if (! $user->admin) accessforbidden(); */ if (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"]); @@ -50,7 +50,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (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"]); @@ -67,10 +67,10 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) * View */ -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("ECMSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup'); print '
'; @@ -100,7 +100,7 @@ else { print ''.img_picto($langs->trans("Disabled"), 'off').''; } - elseif(! empty($conf->global->USER_MAIL_REQUIRED)) + elseif (!empty($conf->global->USER_MAIL_REQUIRED)) { print ''.img_picto($langs->trans("Enabled"), 'on').''; } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index d4415c6c1b6..74592ff777a 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -231,7 +231,7 @@ if ($action == 'confirm_collect') $form = new Form($db); $formfile = new FormFile($db); -$help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; +$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; llxHeader('', 'EmailCollector', $help_url); @@ -577,14 +577,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; // support hook for add action - $parameters = array( 'arrayoftypes' => $arrayoftypes ) ; + $parameters = array('arrayoftypes' => $arrayoftypes); $res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action); - if($res) + if ($res) $arrayoftypes = $hookmanager->resArray; else - foreach($hookmanager->resArray as $k=>$desc) - $arrayoftypes[$k]=$desc; + foreach ($hookmanager->resArray as $k=>$desc) + $arrayoftypes[$k] = $desc; print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300'); diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 120fce37b4c..d2c52da585b 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -170,7 +170,7 @@ if (empty($reshook)) $form = new Form($db); -$help_url="EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; +$help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d76f77dd018..be9e7091300 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -37,18 +37,18 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "sendings", "deliveries", "other")); -if (! $user->admin) +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='shipping'; +$type = 'shipping'; if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { - $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; + $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; } @@ -60,9 +60,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst=GETPOST('maskconstexpedition', 'alpha'); - $maskvalue=GETPOST('maskexpedition', 'alpha'); - if (! empty($maskconst)) + $maskconst = GETPOST('maskconstexpedition', 'alpha'); + $maskvalue = GETPOST('maskexpedition', 'alpha'); + if (!empty($maskconst)) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (isset($res)) @@ -76,7 +76,7 @@ if ($action == 'updateMask') elseif ($action == 'set_param') { - $freetext=GETPOST('SHIPPING_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('SHIPPING_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); if ($res <= 0) { @@ -84,7 +84,7 @@ elseif ($action == 'set_param') setEventMessages($langs->trans("Error"), null, 'errors'); } - $draft=GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); if ($res <= 0) { @@ -92,7 +92,7 @@ elseif ($action == 'set_param') setEventMessages($langs->trans("Error"), null, 'errors'); } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -100,20 +100,20 @@ elseif ($action == 'set_param') elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $exp = new Expedition($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/expedition/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -186,13 +186,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("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print '
'; $head = expedition_admin_prepare_head(); @@ -223,11 +223,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, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 15) == 'mod_expedition_' && 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'; @@ -236,7 +236,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 '\n"; @@ -246,11 +246,11 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -267,21 +267,21 @@ foreach ($dirmodels as $reldir) } print ''; - $expedition=new Expedition($db); + $expedition = new Expedition($db); $expedition->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $expedition); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $expedition); 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).'
'; } } @@ -307,19 +307,19 @@ print '
'.$langs->trans("CodeBarGenerator").'
'.$langs->trans("EnableFileCache").''; print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1); print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; print $module->info(); @@ -171,9 +171,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 $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='BANK_CHEQUERECEIPT_FREE_TEXT'; +$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -263,7 +263,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/clicktodial.php b/htdocs/admin/clicktodial.php index 3fb3340a702..36205697e89 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -40,8 +40,8 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $result1=dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result2=dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); if ($result1 >= 0 && $result2 >= 0) { @@ -60,10 +60,10 @@ if ($action == 'setvalue' && $user->admin) $user->fetch_clicktodial(); -$wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es'; +$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es'; llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup'); print ''.$langs->trans("ClickToDialDesc")."
\n"; @@ -90,7 +90,7 @@ print '
'; print $langs->trans("DefaultLink").''; -print 'global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS?' disabled="disabled"':'').' value="'.$conf->global->CLICKTODIAL_URL.'">
'; +print 'global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS ? ' disabled="disabled"' : '').' value="'.$conf->global->CLICKTODIAL_URL.'">
'; print ajax_autoselect('CLICKTODIAL_URL'); print '
'; print $langs->trans("ClickToDialUrlDesc").'
'; @@ -111,24 +111,24 @@ print '

'; - print ''; + print ''; print $langs->trans("LinkToTestClickToDial", $user->login).' : '; print ''; print ''; print ''; - $setupcomplete=1; - if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete=0; - if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete=0; - if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete=0; + $setupcomplete = 1; + if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0; + if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0; + if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0; if ($setupcomplete) { diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index b7e874beec2..8d5925e363d 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -46,13 +46,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -69,11 +69,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Receptions"); +$textobject = $langs->transnoentitiesnoconv("Receptions"); llxHeader('', $langs->trans("ReceptionsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ReceptionsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -114,7 +114,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 3c5d7ec0017..3229eda7365 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -533,7 +533,7 @@ print '
'.$langs->trans("SocialNetworksInformation").'
'; print ''; $networkconst = 'MAIN_INFO_SOCIETE_'.strtoupper($networkkey).'_URL'; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 70b6f303627..cdfa15d9069 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -83,7 +83,7 @@ if ($action == 'update') } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -99,9 +99,9 @@ if ($action == 'update') llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup'); print '
'; diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index b3265479d38..fd93b0fa83d 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -35,7 +35,7 @@ $langs->loadLangs(array('admin', 'sendings', 'deliveries')); if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); /* @@ -43,7 +43,7 @@ $action=GETPOST('action', 'alpha'); */ // Shipment note -if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) +if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { // This option should always be set to on when module is on. dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); @@ -66,7 +66,7 @@ if ($action == 'disable_sending') // Delivery note if ($action == 'activate_delivery') { - dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this + dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1", 'chaine', 0, '', $conf->entity); header("Location: confexped.php"); exit; @@ -84,11 +84,11 @@ elseif ($action == 'disable_delivery') */ $dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/"; -$form=new Form($db); +$form = new Form($db); llxHeader("", $langs->trans("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print '
'; $head = expedition_admin_prepare_head(); diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 1f04b96f670..e228ab58e8a 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -30,22 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$rowid=GETPOST('rowid', 'int'); -$entity=GETPOST('entity', 'int'); -$action=GETPOST('action', 'alpha'); -$update=GETPOST('update', 'alpha'); -$delete=GETPOST('delete', 'none'); // Do not use alpha here -$debug=GETPOST('debug', 'int'); -$consts=GETPOST('const', 'array'); -$constname=GETPOST('constname', 'alphanohtml'); -$constvalue=GETPOST('constvalue', 'none'); // We shoul dbe able to send everything here -$constnote=GETPOST('constnote', 'alpha'); +$rowid = GETPOST('rowid', 'int'); +$entity = GETPOST('entity', 'int'); +$action = GETPOST('action', 'alpha'); +$update = GETPOST('update', 'alpha'); +$delete = GETPOST('delete', 'none'); // Do not use alpha here +$debug = GETPOST('debug', 'int'); +$consts = GETPOST('const', 'array'); +$constname = GETPOST('constname', 'alphanohtml'); +$constvalue = GETPOST('constvalue', 'none'); // We shoul dbe able to send everything here +$constnote = GETPOST('constnote', '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 = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -63,7 +63,7 @@ if (empty($sortorder)) $sortorder = 'ASC'; if ($action == 'add' || (GETPOST('add') && $action != 'update')) { - $error=0; + $error = 0; if (empty($constname)) { @@ -76,15 +76,15 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) $error++; } - if (! $error) + if (!$error) { if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=""; - $constname=""; - $constvalue=""; - $constnote=""; + $action = ""; + $constname = ""; + $constvalue = ""; + $constnote = ""; } else { @@ -94,12 +94,12 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) } // Mass update -if (! empty($consts) && $action == 'update') +if (!empty($consts) && $action == 'update') { - $nbmodified=0; - foreach($consts as $const) + $nbmodified = 0; + foreach ($consts as $const) { - if (! empty($const["check"])) + if (!empty($const["check"])) { if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) { @@ -112,16 +112,16 @@ if (! empty($consts) && $action == 'update') } } if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=''; + $action = ''; } // Mass delete -if (! empty($consts) && $action == 'delete') +if (!empty($consts) && $action == 'delete') { - $nbdeleted=0; - foreach($consts as $const) + $nbdeleted = 0; + foreach ($consts as $const) { - if (! empty($const["check"])) // Is checkbox checked + if (!empty($const["check"])) // Is checkbox checked { if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) { @@ -134,7 +134,7 @@ if (! empty($consts) && $action == 'delete') } } if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - $action=''; + $action = ''; } // Delete line from delete picto @@ -157,7 +157,7 @@ if ($action == 'delete') $form = new Form($db); -$wikihelp='EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios'; +$wikihelp = 'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios'; llxHeader('', $langs->trans("Setup"), $wikihelp); // Add logic to show/hide buttons @@ -191,7 +191,7 @@ print "
\n"; $param = ''; -print '
entity) && $debug)?'?debug=1':'').'" method="POST">'; +print 'entity) && $debug) ? '?debug=1' : '').'" method="POST">'; print ''; print ''; print ''; @@ -204,7 +204,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, ' print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; -if (! empty($conf->multicompany->enabled) && !$user->entity) +if (!empty($conf->multicompany->enabled) && !$user->entity) { print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; } @@ -224,7 +224,7 @@ print '
'; print ''; print ''; @@ -243,19 +243,19 @@ print '
'; print ''; @@ -310,7 +310,7 @@ if ($result) } else { - print ''.img_delete().''; + print ''.img_delete().''; } print "
\n"; print '
'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; // This slow seriously output +print ''; // This slow seriously output print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput"); 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("SendingsReceiptModel"), '', ''); // Defini tableau def de modele invoice -$type="shipping"; +$type = "shipping"; $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); @@ -346,42 +346,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/expedition".$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; @@ -416,18 +416,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); @@ -474,15 +474,15 @@ print ""; print "".$langs->trans("Parameter")."\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 $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='SHIPPING_FREE_TEXT'; +$variablename = 'SHIPPING_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -490,7 +490,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 "\n"; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index 69ad145e7df..6ff8cd42669 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -43,13 +43,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='expedition'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'expedition'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -66,11 +66,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Sendings"); +$textobject = $langs->transnoentitiesnoconv("Sendings"); llxHeader('', $langs->trans("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -111,7 +111,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 51e3de9c80d..8b27aec895e 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -44,13 +44,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='expeditiondet'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'expeditiondet'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Sendings"); +$textobject = $langs->transnoentitiesnoconv("Sendings"); llxHeader('', $langs->trans("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -112,7 +112,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index b55f5cba2bf..af1c7c88698 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -37,13 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'trips', 'other')); -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='expensereport'; +$type = 'expensereport'; /* @@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst=GETPOST('maskconst', 'alpha'); - $maskvalue=GETPOST('maskvalue', 'alpha'); + $maskconst = GETPOST('maskconst', 'alpha'); + $maskvalue = GETPOST('maskvalue', 'alpha'); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -72,22 +72,22 @@ if ($action == 'updateMask') elseif ($action == 'specimen') // For fiche inter { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $inter = new ExpenseReport($db); $inter->initAsSpecimen(); - $inter->status = 0; // Force statut draft to show watermark - $inter->fk_statut = 0; // Force statut draft to show watermark + $inter->status = 0; // Force statut draft to show watermark + $inter->fk_statut = 0; // Force statut draft to show watermark // 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/expensereport/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -166,15 +166,15 @@ elseif ($action == 'setoptions') { $db->begin(); - $freetext= GETPOST('EXPENSEREPORT_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('EXPENSEREPORT_FREE_TEXT', 'none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res1 > 0 || ! $res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -191,17 +191,17 @@ elseif ($action == 'setoptions') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader('', $langs->trans("ExpenseReportsSetup")); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); -$head=expensereport_admin_prepare_head(); +$head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), -1, 'trip'); @@ -231,18 +231,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, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 18) == 'mod_expensereport_' && 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($db); // 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()) @@ -253,9 +253,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model 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 ''."\n"; @@ -272,21 +272,21 @@ foreach ($dirmodels as $reldir) } print ''; - $exp=new ExpenseReport($db); + $exp = new ExpenseReport($db); $exp->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($exp); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($exp); 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).'
'; } } @@ -311,17 +311,17 @@ print "
\n"; print load_fiche_titre($langs->trans("TemplatePDFExpenseReports"), '', ''); // Defini tableau def des modeles -$type='expensereport'; +$type = 'expensereport'; $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); @@ -352,17 +352,17 @@ foreach ($dirmodels as $reldir) 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)) { @@ -416,15 +416,15 @@ 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("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("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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); print ''; print $form->textwithpicto('', $htmltooltip, -1, 0); print ''; @@ -472,15 +472,15 @@ print ''.$langs->trans("Parameter").''; print ''; print "\n"; -$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 $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='EXPENSEREPORT_FREE_TEXT'; +$variablename = 'EXPENSEREPORT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -488,7 +488,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 ''."\n"; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 61dcf3dcf66..bc0f52120fb 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -40,13 +40,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='expensereport'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'expensereport'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -65,7 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; llxHeader('', $langs->trans("ExpenseReportsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); @@ -105,7 +105,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index 0933d823297..83bb28ca440 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","trips","errors","other","dict")); +$langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); if (!$user->admin) accessforbidden(); @@ -88,12 +88,12 @@ $rangesbycateg = ExpenseReportIk::getAllRanges(); llxHeader('', $langs->trans("ExpenseReportsSetup")); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup'); -$head=expensereport_admin_prepare_head(); +$head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); echo $langs->trans('ExpenseReportIkDesc'); @@ -125,11 +125,11 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) if ($Tab['active'] == 0) continue; - $tranche=1; + $tranche = 1; foreach ($Tab['ranges'] as $k => $range) { - if (isset($Tab['ranges'][$k+1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k+1]->range_ik-1)); + if (isset($Tab['ranges'][$k + 1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1)); else $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik); if ($range->range_active == 0) $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 1b41205b3b5..f2412175880 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -38,8 +38,8 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); $def = array(); -$lastexternalrss=0; -$action=GETPOST('action', 'aZ09'); +$lastexternalrss = 0; +$action = GETPOST('action', 'aZ09'); /* @@ -47,10 +47,10 @@ $action=GETPOST('action', 'aZ09'); */ // positionne la variable pour le nombre de rss externes -$sql ="SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const"; -$sql.=" WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'"; +$sql = "SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const"; +$sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'"; //print $sql; -$result=$db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9 +$result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9 if ($result) { while ($obj = $db->fetch_object($result)) @@ -66,12 +66,12 @@ else if ($action == 'add' || GETPOST("modify")) { - $external_rss_title = "external_rss_title_" . GETPOST("norss", 'int'); - $external_rss_urlrss = "external_rss_urlrss_" . GETPOST("norss", 'int'); + $external_rss_title = "external_rss_title_".GETPOST("norss", 'int'); + $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int'); - if (! empty($_POST[$external_rss_urlrss])) + if (!empty($_POST[$external_rss_urlrss])) { - $boxlabel='(ExternalRSSInformations)'; + $boxlabel = '(ExternalRSSInformations)'; //$external_rss_url = "external_rss_url_" . $_POST["norss"]; $db->begin(); @@ -95,16 +95,16 @@ if ($action == 'add' || GETPOST("modify")) { // Ajoute boite box_external_rss dans definition des boites $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; - $sql.= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')"; - if (! $db->query($sql)) + $sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')"; + if (!$db->query($sql)) { dol_print_error($db); $err++; } } - $result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); + $result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity); + if ($result1) $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); if ($result1 && $result2) { @@ -128,27 +128,27 @@ if ($_POST["delete"]) // Supprime boite box_external_rss de definition des boites $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; + $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; - $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); + $obj = $db->fetch_object($resql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND box_id = ".$obj->rowid; - $resql=$db->query($sql); + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND box_id = ".$obj->rowid; + $resql = $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE rowid = ".$obj->rowid; - $resql=$db->query($sql); + $sql .= " WHERE rowid = ".$obj->rowid; + $resql = $db->query($sql); - if (! $resql) + if (!$resql) { $db->rollback(); dol_print_error($db, "sql=".$sql); @@ -168,8 +168,8 @@ if ($_POST["delete"]) } - $result1=dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity); - if ($result1) $result2=dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); + $result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity); + if ($result1) $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); if ($result1 && $result2) { @@ -192,7 +192,7 @@ if ($_POST["delete"]) llxHeader('', $langs->trans("ExternalRSSSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExternalRSSSetup"), $linkback, 'title_setup'); print '
'; @@ -207,13 +207,13 @@ print ''.$langs->trans("Example").''; print ''; print ''; print ''.$langs->trans("Title").''; -print ''; +print ''; print ''.$langs->trans('RSSUrlExample').''; print ''; print ''; print ''.$langs->trans('RSSUrl').''; -print ''; +print ''; print 'http://news.google.com/news?ned=us&topic=h&output=rss
http://www.dolibarr.org/rss'; print ''; print ''; @@ -221,22 +221,22 @@ print ''; print '
'; print ''; print ''; -print ''; +print ''; print '


'; print ''; -$sql ="SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def"; -$sql.=" WHERE file = 'box_external_rss.php'"; -$sql.=" ORDER BY note"; +$sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def"; +$sql .= " WHERE file = 'box_external_rss.php'"; +$sql .= " ORDER BY note"; dol_syslog("select rss boxes", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $num =$db->num_rows($resql); - $i=0; + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { @@ -244,11 +244,11 @@ if ($resql) preg_match('/^([0-9]+)/i', $obj->note, $reg); $idrss = $reg[1]; - $keyrsstitle="EXTERNAL_RSS_TITLE_".$idrss; - $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; + $keyrsstitle = "EXTERNAL_RSS_TITLE_".$idrss; + $keyrssurl = "EXTERNAL_RSS_URLRSS_".$idrss; //print "x".$idrss; - $rssparser=new RssParser($db); + $rssparser = new RssParser($db); $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); print "
"; @@ -258,7 +258,7 @@ if ($resql) print ''; print ""; - print "".$langs->trans("RSS")." ".($i+1).""; + print "".$langs->trans("RSS")." ".($i + 1).""; print ''; print "trans("Modify")."\">"; print "   "; @@ -270,13 +270,13 @@ if ($resql) print ''; print "".$langs->trans("Title").""; - print "global->$keyrsstitle) . "\">"; + print "global->$keyrsstitle)."\">"; print ""; print ''; print "".$langs->trans("URL").""; - print "global->$keyrssurl) . "\">"; + print "global->$keyrssurl)."\">"; print ""; @@ -303,9 +303,9 @@ if ($resql) print ''; print "".$langs->trans("Logo").""; print ''; - $imageurl=$rssparser->getImageUrl(); - $linkrss=$rssparser->getLink(); - if (! preg_match('/^http/', $imageurl)) $imageurl=$linkrss.$imageurl; + $imageurl = $rssparser->getImageUrl(); + $linkrss = $rssparser->getLink(); + if (!preg_match('/^http/', $imageurl)) $imageurl = $linkrss.$imageurl; if ($imageurl) print ''; else print $langs->trans("None"); print ''; diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 408b762358e..f565169b111 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'other', 'bills')); -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='invoice'; +$type = 'invoice'; /* @@ -57,17 +57,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader( "", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' ); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); @@ -107,7 +107,7 @@ $metas = array( _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas); // Conditions paiements -$inputCount = empty($inputCount)?1:($inputCount+1); +$inputCount = empty($inputCount) ? 1 : ($inputCount + 1); print ''; print ''.$langs->trans('PaymentConditionsShortRetainedWarranty').''; print ' '; @@ -159,7 +159,7 @@ function _printOnOff($confkey, $title = false, $desc = '') global $langs; print ''; - print ''.($title?$title:$langs->trans($confkey)); + print ''.($title ? $title : $langs->trans($confkey)); if (!empty($desc)) { print '
'.$langs->trans($desc).''; } @@ -187,14 +187,14 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra { global $langs, $conf, $db, $inputCount; - $inputCount = empty($inputCount)?1:($inputCount+1); - $form=new Form($db); + $inputCount = empty($inputCount) ? 1 : ($inputCount + 1); + $form = new Form($db); $defaultMetas = array( 'name' => 'value'.$inputCount ); - if ($type!='textarea') { + if ($type != 'textarea') { $defaultMetas['type'] = 'text'; $defaultMetas['value'] = $conf->global->{$confkey}; } @@ -210,9 +210,9 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra print ''; if (!empty($help)) { - print $form->textwithtooltip(($title?$title:$langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, '')); + print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, '')); } else { - print $title?$title:$langs->trans($confkey); + print $title ? $title : $langs->trans($confkey); } if (!empty($desc)) { @@ -225,7 +225,7 @@ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = arra print ''; print ''; - if ($type=='textarea') { + if ($type == 'textarea') { print ''; } else { print ''; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index ad077361fe8..00995a302a5 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha'); // dolibarr_readonly // dolibarr_mailings // Full (not sure this one is used) -$mode=GETPOST('mode')?GETPOST('mode', 'alpha'):'dolibarr_notes'; +$mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes'; if (!$user->admin) accessforbidden(); @@ -56,12 +56,12 @@ $modules = array( // Conditions pour que l'option soit proposee $conditions = array( 'SOCIETE' => 1, -'PRODUCTDESC' => (! empty($conf->product->enabled) || ! empty($conf->service->enabled)), -'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->supplier_proposal->enabled) || ! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)), +'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)), +'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), 'USERSIGN' => 1, -'MAILING' => ! empty($conf->mailing->enabled), -'MAIL' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)), -'TICKET' => ! empty($conf->ticket->enabled) +'MAILING' => !empty($conf->mailing->enabled), +'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), +'TICKET' => !empty($conf->ticket->enabled) ); // Picto $picto = array( @@ -80,13 +80,13 @@ $picto = array( * Actions */ -foreach($modules as $const => $desc) +foreach ($modules as $const => $desc) { if ($action == 'activate_'.strtolower($const)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires - if ($const == 'PRODUCTDESC' && ! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); } @@ -106,24 +106,24 @@ if (GETPOST('save', 'alpha')) $error = 0; $fckeditor_skin = GETPOST('fckeditor_skin', 'alpha'); - if (! empty($fckeditor_skin)) { - if (! dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!empty($fckeditor_skin)) { + if (!dolibarr_set_const($db, 'FCKEDITOR_SKIN', $fckeditor_skin, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } $fckeditor_test = GETPOST('formtestfield'); - if (! empty($fckeditor_test)) { - if (! dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!empty($fckeditor_test)) { + if (!dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -139,7 +139,7 @@ if (GETPOST('save', 'alpha')) llxHeader(); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup'); print '
'; @@ -156,17 +156,17 @@ else print "\n"; // Modules - foreach($modules as $const => $desc) + foreach ($modules as $const => $desc) { // Si condition non remplie, on ne propose pas l'option - if (! $conditions[$const]) continue; + if (!$conditions[$const]) continue; print ''; print ''.img_object("", $picto[$const]).''; print ''.$langs->trans($desc).''; print ''; $constante = 'FCKEDITOR_ENABLE_'.$const; - $value = (isset($conf->global->$constante)?$conf->global->$constante:0); + $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; @@ -185,31 +185,31 @@ else print '
'."\n"; print '
'."\n"; - print ''; + print ''; // Skins show_skin(null, 1); print '
'."\n"; - $listofmodes=array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); - $linkstomode=''; - foreach($listofmodes as $newmode) + $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); + $linkstomode = ''; + foreach ($listofmodes as $newmode) { - if ($linkstomode) $linkstomode.=' - '; - $linkstomode.=''; - if ($mode == $newmode) $linkstomode.=''; - $linkstomode.=$newmode; - if ($mode == $newmode) $linkstomode.=''; - $linkstomode.=''; + if ($linkstomode) $linkstomode .= ' - '; + $linkstomode .= ''; + if ($mode == $newmode) $linkstomode .= ''; + $linkstomode .= $newmode; + if ($mode == $newmode) $linkstomode .= ''; + $linkstomode .= ''; } - $linkstomode.=''; + $linkstomode .= ''; print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); print ''; if ($mode != 'Full_inline') { - $uselocalbrowser=true; - $readonly=($mode=='dolibarr_readonly'?1:0); - $editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); + $uselocalbrowser = true; + $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); + $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); $editor->Create(); } else diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index 38074953e26..a661f3a8e9a 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -32,7 +32,7 @@ if (!$user->admin) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array("admin","errors")); +$langs->loadLangs(array("admin", "errors")); $action = GETPOST('action', 'aZ09'); @@ -43,25 +43,25 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'set') { - $error=0; + $error = 0; - $gimcdf= GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); + $gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); - if (! $gimcdf && ! file_exists($gimcdf)) + if (!$gimcdf && !file_exists($gimcdf)) { setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); - if (! $res1 > 0) $error++; + if (!$res1 > 0) $error++; $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); - if (! $res2 > 0) $error++; + if (!$res2 > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -72,26 +72,26 @@ if ($action == 'set') } } -if (! isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2'; +if (!isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2'; /* * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("GeoIPMaxmindSetup"), $linkback, 'title_setup'); print '
'; -$version=''; -$geoip=''; -if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) +$version = ''; +$geoip = ''; +if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) { - $geoip=new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); + $geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); } // Mode @@ -112,7 +112,7 @@ $arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2')); if ($conf->global->GEOIP_VERSION == 'php') { - if ($geoip) $version=$geoip->getVersion(); + if ($geoip) $version = $geoip->getVersion(); if ($version) { print '
'.$langs->trans("Version").': '.$version; @@ -139,12 +139,12 @@ print '
'; print $langs->trans("NoteOnPathLocation").'
'; -$url1='http://www.maxmind.com/en/city?rId=awstats'; +$url1 = 'http://www.maxmind.com/en/city?rId=awstats'; print $langs->trans("YouCanDownloadFreeDatFileTo", ''.$url1.''); print '
'; -$url2='http://www.maxmind.com/en/city?rId=awstats'; +$url2 = 'http://www.maxmind.com/en/city?rId=awstats'; print $langs->trans("YouCanDownloadAdvancedDatFileTo", ''.$url2.''); if ($geoip) @@ -152,15 +152,15 @@ if ($geoip) print '

'; print '
'.$langs->trans("TestGeoIPResult", $ip).':'; - $ip='24.24.24.24'; + $ip = '24.24.24.24'; print '
'.$ip.' -> '; - $result=dol_print_ip($ip, 1); + $result = dol_print_ip($ip, 1); if ($result) print $result; else print $langs->trans("Error"); - $ip='2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France + $ip = '2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France print '
'.$ip.' -> '; - $result=dol_print_ip($ip, 1); + $result = dol_print_ip($ip, 1); if ($result) print $result; else print $langs->trans("Error"); @@ -175,18 +175,18 @@ if ($geoip) //var_dump($_SERVER); $ip = getUserRemoteIP(); //$ip='91.161.249.43'; - $isip=is_ip($ip); + $isip = is_ip($ip); if ($isip == 1) { print '
'.$ip.' -> '; - $result=dol_print_ip($ip, 1); + $result = dol_print_ip($ip, 1); if ($result) print $result; else print $langs->trans("Error"); } else { print '
'.$ip.' -> '; - $result=dol_print_ip($ip, 1); + $result = dol_print_ip($ip, 1); if ($result) print $result; else print $langs->trans("NotAPublicIp"); } diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index b9c32a8b9c9..fc0bac8a019 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -40,13 +40,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='holiday'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'holiday'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -65,7 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; llxHeader('', $langs->trans("HolidaySetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); $head = holiday_admin_prepare_head(); @@ -105,7 +105,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index c3ce7724752..1a55fbc04ee 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -39,23 +39,23 @@ $hookmanager->initHooks(array('homesetup')); $form = new Form($db); -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); -if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) +if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { - $conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); - if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) + $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); + if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { - $i=0; + $i = 0; while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) { - $tmp=explode('|', $reg[1]); - if (! empty($tmp[1])) $langs->load($tmp[1]); - $conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); + $tmp = explode('|', $reg[1]); + if (!empty($tmp[1])) $langs->load($tmp[1]); + $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); $i++; } diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index edb0c800720..83505747fcd 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -40,38 +40,38 @@ if (!$user->admin) $action = GETPOST('action', 'aZ09'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('adminldap','globaladmin')); +$hookmanager->initHooks(array('adminldap', 'globaladmin')); /* * Actions */ -$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)) { if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes"), 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -90,20 +90,20 @@ if (empty($reshook)) llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -$form=new Form($db); +$form = new Form($db); print ''; @@ -121,56 +121,56 @@ print "\n"; // Synchro utilisateurs/groupes active print ''.$langs->trans("LDAPDnSynchroActive").''; -$arraylist=array(); -$arraylist['0']=$langs->trans("No"); -$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr"); -$arraylist['dolibarr2ldap']=$langs->trans("DolibarrToLDAP"); +$arraylist = array(); +$arraylist['0'] = $langs->trans("No"); +$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr"); +$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); print ''.$langs->trans("LDAPDnSynchroActiveExample"); -if ($conf->global->LDAP_SYNCHRO_ACTIVE && ! $conf->global->LDAP_USER_DN) +if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) { print '
'.$langs->trans("LDAPSetupNotComplete").''; } print ''; // Synchro contact active -if (! empty($conf->societe->enabled)) +if (!empty($conf->societe->enabled)) { print ''.$langs->trans("LDAPDnContactActive").''; - $arraylist=array(); - $arraylist['0']=$langs->trans("No"); - $arraylist['1']=$langs->trans("DolibarrToLDAP"); + $arraylist = array(); + $arraylist['0'] = $langs->trans("No"); + $arraylist['1'] = $langs->trans("DolibarrToLDAP"); print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE); print ''.$langs->trans("LDAPDnContactActiveExample").''; } // Synchro member active -if (! empty($conf->adherent->enabled)) +if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberActive").''; - $arraylist=array(); - $arraylist['0']=$langs->trans("No"); - $arraylist['1']=$langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; + $arraylist = array(); + $arraylist['0'] = $langs->trans("No"); + $arraylist['1'] = $langs->trans("DolibarrToLDAP"); + $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE); print ''.$langs->trans("LDAPDnMemberActiveExample").''; } // Synchro member type active -if (! empty($conf->adherent->enabled)) +if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberTypeActive").''; - $arraylist=array(); - $arraylist['0']=$langs->trans("No"); - $arraylist['1']=$langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; + $arraylist = array(); + $arraylist['0'] = $langs->trans("No"); + $arraylist['1'] = $langs->trans("DolibarrToLDAP"); + $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE); print ''.$langs->trans("LDAPDnMemberTypeActiveExample").''; } // Fields from hook -$parameters=array(); -$reshook=$hookmanager->executeHooks('addAdminLdapOptions', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('addAdminLdapOptions', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -181,18 +181,18 @@ print "\n"; // Type print ''.$langs->trans("Type").''; -$arraylist=array(); -$arraylist['activedirectory']='Active Directory'; -$arraylist['openldap']='OpenLdap'; -$arraylist['egroupware']='Egroupware'; +$arraylist = array(); +$arraylist['activedirectory'] = 'Active Directory'; +$arraylist['openldap'] = 'OpenLdap'; +$arraylist['egroupware'] = 'Egroupware'; print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE); print ' '; // Version print ''.$langs->trans("Version").''; -$arraylist=array(); -$arraylist['3']='Version 3'; -$arraylist['2']='Version 2'; +$arraylist = array(); +$arraylist['3'] = 'Version 3'; +$arraylist['2'] = 'Version 2'; print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION); print ''.$langs->trans("LDAPServerProtocolVersion").''; @@ -210,7 +210,7 @@ print ''.$langs->trans("LDAPServerExample").''; // Port print ''.$langs->trans("LDAPServerPort").''; -if (! empty($conf->global->LDAP_SERVER_PORT)) +if (!empty($conf->global->LDAP_SERVER_PORT)) { print ''; } @@ -227,9 +227,9 @@ print ''.$langs->trans("LDAPServerDnExample").''; // Utiliser TLS print ''.$langs->trans("LDAPServerUseTLS").''; -$arraylist=array(); -$arraylist['0']=$langs->trans("No"); -$arraylist['1']=$langs->trans("Yes"); +$arraylist = array(); +$arraylist['0'] = $langs->trans("No"); +$arraylist['1'] = $langs->trans("Yes"); print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS); print ''.$langs->trans("LDAPServerUseTLSExample").''; @@ -244,9 +244,9 @@ print ''.$langs->trans("LDAPAdminDnExample").''; // Pass print ''.$langs->trans("LDAPPassword").''; -if (! empty($conf->global->LDAP_ADMIN_PASS)) +if (!empty($conf->global->LDAP_ADMIN_PASS)) { - print '';// je le met en visible pour test + print ''; // je le met en visible pour test } else { @@ -270,14 +270,14 @@ print '
'; */ if (function_exists("ldap_connect")) { - if (! empty($conf->global->LDAP_SERVER_HOST)) + if (!empty($conf->global->LDAP_SERVER_HOST)) { print ''.$langs->trans("LDAPTestConnect").'

'; } if ($_GET["action"] == 'test') { - $ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf + $ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf $result = $ldap->connect_bind(); if ($result > 0) @@ -287,7 +287,7 @@ if (function_exists("ldap_connect")) print ''.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; print '
'; - if ($conf->global->LDAP_ADMIN_DN && ! empty($conf->global->LDAP_ADMIN_PASS)) + if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) { if ($result == 2) { diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index d2984cab6bf..834bde4eea5 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","errors")); +$langs->loadLangs(array("admin", "errors")); if (!$user->admin) accessforbidden(); @@ -46,35 +46,35 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -92,17 +92,17 @@ if ($action == 'setvalue' && $user->admin) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -150,98 +150,98 @@ print "\n"; print ''.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FULLNAME?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FULLNAME ? ' checked' : '').">"; print ''; // Name print ''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_NAME?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_NAME ? ' checked' : '').">"; print ''; // Firstname print ''.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME ? ' checked' : '').">"; print ''; // Company print ''.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COMPANY?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COMPANY ? ' checked' : '').">"; print ''; // Mail print ''.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MAIL?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MAIL ? ' checked' : '').">"; print ''; // Phone pro print ''.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_PHONE?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_PHONE ? ' checked' : '').">"; print ''; // Phone home print ''.$langs->trans("LDAPFieldHomePhone").''; print ''; print ''.$langs->trans("LDAPFieldHomePhoneExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_HOMEPHONE ? ' checked' : '').">"; print ''; // Mobile print ''.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MOBILE?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MOBILE ? ' checked' : '').">"; print ''; // Skype print ''.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_SKYPE?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_SKYPE ? ' checked' : '').">"; print ''; // Fax print ''.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FAX?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FAX ? ' checked' : '').">"; print ''; // Address print ''.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ADDRESS?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ADDRESS ? ' checked' : '').">"; print ''; // ZIP print ''.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ZIP?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ZIP ? ' checked' : '').">"; print ''; // TOWN print ''.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").''; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_TOWN?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_TOWN ? ' checked' : '').">"; print ''; // COUNTRY print ''.$langs->trans("LDAPFieldCountry").''; print ''; print ' '; -print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COUNTRY?' checked':'').">"; +print 'global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COUNTRY ? ' checked' : '').">"; print ''; print ''; @@ -258,11 +258,11 @@ print ''; /* * Test de la connexion */ -$butlabel=$langs->trans("LDAPTestSynchroContact"); -$testlabel='test'; -$key=$conf->global->LDAP_KEY_CONTACTS; -$dn=$conf->global->LDAP_CONTACT_DN; -$objectclass=$conf->global->LDAP_CONTACT_OBJECT_CLASS; +$butlabel = $langs->trans("LDAPTestSynchroContact"); +$testlabel = 'test'; +$key = $conf->global->LDAP_KEY_CONTACTS; +$dn = $conf->global->LDAP_CONTACT_DN; +$objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); @@ -272,21 +272,21 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'test') { // Creation objet - $object=new Contact($db); + $object = new Contact($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index f2e8002c8df..f6fa74cb79d 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -47,51 +47,51 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; // Members - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++; // Subscriptions - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -109,17 +109,17 @@ if ($action == 'setvalue' && $user->admin) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -176,14 +176,14 @@ print "\n"; print ''.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''; -print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_FULLNAME)?' checked':'').">"; +print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_FULLNAME) ? ' checked' : '').">"; print ''; // Name print ''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''; -print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_NAME)?' checked':'').">"; +print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_NAME) ? ' checked' : '').">"; print ''; // Firstname @@ -197,14 +197,14 @@ print ''; print ''.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''; -print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN)?' checked':'').">"; +print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN) ? ' checked' : '').">"; print ''; // Login samba print ''.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''; -print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA)?' checked':'').">"; +print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA) ? ' checked' : '').">"; print ''; // Password not crypted @@ -225,7 +225,7 @@ print ''; print ''.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''; -print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_MAIL)?' checked':'').">"; +print 'global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_MAIL) ? ' checked' : '').">"; print ''; // Phone pro @@ -379,13 +379,13 @@ print ''; /* * Test de la connexion */ -if (! empty($conf->global->LDAP_MEMBER_ACTIVE)) +if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) { - $butlabel=$langs->trans("LDAPTestSynchroMember"); - $testlabel='testmember'; - $key=$conf->global->LDAP_KEY_MEMBERS; - $dn=$conf->global->LDAP_MEMBER_DN; - $objectclass=$conf->global->LDAP_MEMBER_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroMember"); + $testlabel = 'testmember'; + $key = $conf->global->LDAP_KEY_MEMBERS; + $dn = $conf->global->LDAP_MEMBER_DN; + $objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -395,21 +395,21 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'testmember') { // Creation objet - $object=new Adherent($db); + $object = new Adherent($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index ef8937713dd..7781cf45676 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -48,44 +48,44 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -103,17 +103,17 @@ if ($action == 'setvalue' && $user->admin) * Visu */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -170,35 +170,35 @@ print "\n"; print ''.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FULLNAME)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FULLNAME) ? ' checked' : '').">"; print ''; // Name print ''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_NAME)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_NAME) ? ' checked' : '').">"; print ''; // Firstname print ''.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FIRSTNAME)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FIRSTNAME) ? ' checked' : '').">"; print ''; // Login unix print ''.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) ? ' checked' : '').">"; print ''; // Login samba print ''.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN_SAMBA)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN_SAMBA) ? ' checked' : '').">"; print ''; // Password not crypted @@ -219,35 +219,35 @@ print ''; print ''.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MAIL)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_MAIL) ? ' checked' : '').">"; print ''; // Phone print ''.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PHONE)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_PHONE) ? ' checked' : '').">"; print ''; // Mobile print ''.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MOBILE)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_MOBILE) ? ' checked' : '').">"; print ''; // Skype print ''.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SKYPE)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SKYPE) ? ' checked' : '').">"; print ''; // Fax print ''.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_FAX) ? ' checked' : '').">"; print ''; // Company @@ -303,7 +303,7 @@ print ''; print ''.$langs->trans("LDAPFieldSid").''; print ''; print ''.$langs->trans("LDAPFieldSidExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked':'').">"; +print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) ? ' checked' : '').">"; print ''; // Group id @@ -350,21 +350,21 @@ print ''; */ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { - $butlabel=$langs->trans("LDAPTestSynchroUser"); - $testlabel='testuser'; - $key=$conf->global->LDAP_KEY_USERS; - $dn=$conf->global->LDAP_USER_DN; - $objectclass=$conf->global->LDAP_USER_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroUser"); + $testlabel = 'testuser'; + $key = $conf->global->LDAP_KEY_USERS; + $dn = $conf->global->LDAP_USER_DN; + $objectclass = $conf->global->LDAP_USER_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { - $butlabel=$langs->trans("LDAPTestSearch"); - $testlabel='testsearchuser'; - $key=$conf->global->LDAP_KEY_USERS; - $dn=$conf->global->LDAP_USER_DN; - $objectclass=$conf->global->LDAP_USER_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSearch"); + $testlabel = 'testsearchuser'; + $key = $conf->global->LDAP_KEY_USERS; + $dn = $conf->global->LDAP_USER_DN; + $objectclass = $conf->global->LDAP_USER_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -373,23 +373,23 @@ if (function_exists("ldap_connect")) if ($action == 'testuser') { // Creation objet - $object=new User($db); + $object = new User($db); $object->initAsSpecimen(); // TODO Mutualize code following with other ldap_xxxx.php pages // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { @@ -423,14 +423,14 @@ if (function_exists("ldap_connect")) if ($action == 'testsearchuser') { // Creation objet - $object=new User($db); + $object = new User($db); $object->initAsSpecimen(); // TODO Mutualize code following with other ldap_xxxx.php pages // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { @@ -454,7 +454,7 @@ if (function_exists("ldap_connect")) ); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement"))); + $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); // Get from LDAP database an array of results $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); @@ -462,16 +462,16 @@ if (function_exists("ldap_connect")) if (is_array($ldapusers)) { - $liste=array(); + $liste = array(); foreach ($ldapusers as $key => $ldapuser) { // Define the label string for this user - $label=''; + $label = ''; foreach ($required_fields as $value) { if ($value) { - $label.=$value."=".$ldapuser[$value]." "; + $label .= $value."=".$ldapuser[$value]." "; } } $liste[$key] = $label; diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 6f52d6dfd12..d828873be36 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -29,20 +29,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'admin')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $currencycode = GETPOST('currencycode', 'alpha'); -$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(! empty($currencycode)?'_'.$currencycode:''); -$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(! empty($currencycode)?'_'.$currencycode:''); -$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(! empty($currencycode)?'_'.$currencycode:''); -$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(! empty($currencycode)?'_'.$currencycode:''); +$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(!empty($currencycode) ? '_'.$currencycode : ''); +$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(!empty($currencycode) ? '_'.$currencycode : ''); +$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(!empty($currencycode) ? '_'.$currencycode : ''); +$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$currencycode : ''); if ($action == 'update') { - $error=0; - $MAXDEC=8; + $error = 0; + $MAXDEC = 8; if ($_POST[$mainmaxdecimalsunit] > $MAXDEC || $_POST[$mainmaxdecimalstot] > $MAXDEC || $_POST[$mainmaxdecimalsshown] > $MAXDEC) @@ -51,7 +51,7 @@ if ($action == 'update') setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); } - if ($_POST[$mainmaxdecimalsunit].(! empty($currencycode)?'_'.$currencycode:'') < 0 + if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 || $_POST[$mainmaxdecimalstot] < 0 || $_POST[$mainmaxdecimalsshown] < 0) { @@ -70,7 +70,7 @@ if ($action == 'update') } } - if (! $error) + if (!$error) { dolibarr_set_const($db, $mainmaxdecimalsunit, $_POST[$mainmaxdecimalsunit], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalstot, $_POST[$mainmaxdecimalstot], 'chaine', 0, '', $conf->entity); @@ -78,7 +78,7 @@ if ($action == 'update') dolibarr_set_const($db, $mainroundingruletot, $_POST[$mainroundingruletot], 'chaine', 0, '', $conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(! empty($currencycode)?'¤cycode='.$currencycode:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '¤cycode='.$currencycode : '')); exit; } } @@ -88,22 +88,22 @@ if ($action == 'update') * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup'); -$currencycode = (! empty($currencycode)?$currencycode:$conf->currency); -$aCurrencies = array($conf->currency); // Default currency always first position +$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency); +$aCurrencies = array($conf->currency); // Default currency always first position -if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) +if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; $sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency'; - $sql.= ' WHERE entity = '.$conf->entity; - $sql.= ' AND code != "'.$conf->currency.'"'; // Default currency always first position + $sql .= ' WHERE entity = '.$conf->entity; + $sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position $resql = $db->query($sql); if ($resql) { @@ -113,7 +113,7 @@ if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURREN } } - if (! empty($aCurrencies) && count($aCurrencies) > 1) + if (!empty($aCurrencies) && count($aCurrencies) > 1) { $head = multicurrencyLimitPrepareHead($aCurrencies); dol_fiche_head($head, $currencycode, '', -1, "multicurrency"); @@ -128,7 +128,7 @@ if ($action == 'edit') print '
'; print ''; print ''; - if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { + if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { print ''; } @@ -139,18 +139,18 @@ if ($action == 'edit') print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''; - print ''; + print ''; print ''; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''; + print ''; print ''; @@ -170,29 +170,29 @@ else print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainmaxdecimalsunit)?$conf->global->$mainmaxdecimalsunit:$conf->global->MAIN_MAX_DECIMALS_UNIT).''; + print ''.(isset($conf->global->$mainmaxdecimalsunit) ? $conf->global->$mainmaxdecimalsunit : $conf->global->MAIN_MAX_DECIMALS_UNIT).''; print ''; print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainmaxdecimalstot)?$conf->global->$mainmaxdecimalstot:$conf->global->MAIN_MAX_DECIMALS_TOT).''; + print ''.(isset($conf->global->$mainmaxdecimalstot) ? $conf->global->$mainmaxdecimalstot : $conf->global->MAIN_MAX_DECIMALS_TOT).''; print ''.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''; - print ''.(isset($conf->global->$mainmaxdecimalsshown)?$conf->global->$mainmaxdecimalsshown:$conf->global->MAIN_MAX_DECIMALS_SHOWN).''; + print ''.(isset($conf->global->$mainmaxdecimalsshown) ? $conf->global->$mainmaxdecimalsshown : $conf->global->MAIN_MAX_DECIMALS_SHOWN).''; print ''; print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainroundingruletot)?$conf->global->$mainroundingruletot:$conf->global->MAIN_ROUNDING_RULE_TOT).''; + print ''.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).''; print ''; print ''; } -if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) +if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { - if (! empty($aCurrencies) && count($aCurrencies) > 1) + if (!empty($aCurrencies) && count($aCurrencies) > 1) { dol_fiche_end(); } @@ -201,7 +201,7 @@ if (! empty($conf->multicurrency->enabled) && ! empty($conf->global->MULTICURREN if (empty($mysoc->country_code)) { $langs->load("errors"); - $warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete")); + $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").''; } else @@ -210,35 +210,35 @@ else print load_fiche_titre($langs->trans("ExamplesWithCurrentSetup"), '', ''); // Always show vat rates with vat 0 - $s=2/7;$qty=1;$vat=0; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 2 / 7; $qty = 1; $vat = 0; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; - $s=10/3;$qty=1;$vat=0; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 10 / 3; $qty = 1; $vat = 0; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; - $s=10/3;$qty=2;$vat=0; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 10 / 3; $qty = 2; $vat = 0; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; // Add vat rates examples specific to country - $vat_rates=array(); + $vat_rates = array(); - $sql="SELECT taux as vat_rate"; - $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0"; - $sql.=" ORDER BY t.taux ASC"; - $resql=$db->query($sql); + $sql = "SELECT taux as vat_rate"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0"; + $sql .= " ORDER BY t.taux ASC"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -255,12 +255,12 @@ else if (count($vat_rates)) { - foreach($vat_rates as $vat) + foreach ($vat_rates as $vat) { - for ($qty=1; $qty<=2; $qty++) + for ($qty = 1; $qty <= 2; $qty++) { - $s=10/3; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 10 / 3; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; @@ -274,15 +274,15 @@ else // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10) // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule. - $s=10/3;$qty=1;$vat=10; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 10 / 3; $qty = 1; $vat = 10; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; - $s=10/3;$qty=2;$vat=10; - $tmparray=calcul_price_total(1, $qty*price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); + $s = 10 / 3; $qty = 2; $vat = 10; + $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc); print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php index 814a865216d..5594273320f 100644 --- a/htdocs/admin/livraison_extrafields.php +++ b/htdocs/admin/livraison_extrafields.php @@ -43,13 +43,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='livraison'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'livraison'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -66,11 +66,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Receivings"); +$textobject = $langs->transnoentitiesnoconv("Receivings"); llxHeader('', $langs->trans("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -111,7 +111,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php index 09bd37eb326..2c9aae6b253 100644 --- a/htdocs/admin/livraisondet_extrafields.php +++ b/htdocs/admin/livraisondet_extrafields.php @@ -44,13 +44,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='livraisondet'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'livraisondet'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -67,11 +67,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Receivings"); +$textobject = $langs->transnoentitiesnoconv("Receivings"); llxHeader('', $langs->trans("SendingsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print "
\n"; @@ -112,7 +112,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 7598d2d8588..921a4a6338c 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -50,18 +50,18 @@ if ($action == 'setvalue') $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha'); $mailingdelay = GETPOST('MAILING_DELAY', 'int'); - $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - $res=dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; // Create temporary encryption key if nedded - $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -80,10 +80,10 @@ if ($action == 'setvalue') llxHeader('', $langs->trans("MailingSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); -if (! empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { print "\n".''; - $nbno=$nbtotal=0; + $nbno = $nbtotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'products'); print '
'."\n"; - $sql ="SELECT count(rowid) as nb, fk_product_type, datec"; - $sql.=" FROM ".MAIN_DB_PREFIX."product"; - $sql.=" WHERE barcode IS NULL OR barcode = ''"; - $sql.=" GROUP BY fk_product_type, datec"; - $sql.=" ORDER BY datec"; - $resql=$db->query($sql); + $sql = "SELECT count(rowid) as nb, fk_product_type, datec"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE barcode IS NULL OR barcode = ''"; + $sql .= " GROUP BY fk_product_type, datec"; + $sql .= " ORDER BY datec"; + $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); + $num = $db->num_rows($resql); - $i=0; - while($i < $num) + $i = 0; + while ($i < $num) { - $obj=$db->fetch_object($resql); - $nbno+=$obj->nb; + $obj = $db->fetch_object($resql); + $nbno += $obj->nb; $i++; } } else dol_print_error($db); - $sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product"; - $resql=$db->query($sql); + $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - $nbtotal=$obj->nb; + $obj = $db->fetch_object($resql); + $nbtotal = $obj->nb; } else dol_print_error($db); @@ -291,26 +291,26 @@ if ($conf->product->enabled || $conf->product->service) if (is_object($modBarCodeProduct)) { print $langs->trans("BarCodeNumberManager").": "; - $objproduct=new Product($db); - print ''.(isset($modBarCodeProduct->name)?$modBarCodeProduct->name:$modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; - $disabled=0; + $objproduct = new Product($db); + print ''.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; + $disabled = 0; } else { - $disabled=1; - $titleno=$langs->trans("NoBarcodeNumberingTemplateDefined"); + $disabled = 1; + $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; } if (empty($nbno)) { - $disabled1=1; + $disabled1 = 1; } print '
'; //print ' '.$langs->trans("ResetBarcodeForAllRecords").'
'; - $moretags1=(($disabled||$disabled1)?' disabled title="'.dol_escape_htmltag($titleno).'"':''); + $moretags1 = (($disabled || $disabled1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); print ''; - $moretags2=(($nbno == $nbtotal)?' disabled':''); + $moretags2 = (($nbno == $nbtotal) ? ' disabled' : ''); print '   '; print ''; print '



'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 3bd7f0097b9..d753b3a66ea 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -33,29 +33,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "blockedlog", "bills")); -if ((! $user->admin && ! $user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden(); +if ((!$user->admin && !$user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden(); $action = GETPOST('action', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'blockedloglist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'blockedloglist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $search_showonlyerrors = GETPOST('search_showonlyerrors', 'int'); -if ($search_showonlyerrors < 0) $search_showonlyerrors=0; +if ($search_showonlyerrors < 0) $search_showonlyerrors = 0; -$search_fk_user=GETPOST('search_fk_user', 'intcomma'); +$search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_start = -1; -if (GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); +if (GETPOST('search_startyear') != '') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear')); $search_end = -1; -if (GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear')); +if (GETPOST('search_endyear') != '') $search_end = dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear')); $search_code = GETPOST('search_code', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w'); +if (($search_start == -1 || empty($search_start)) && !GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w'); // 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 = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -64,8 +64,8 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (empty($sortfield)) $sortfield='rowid'; -if (empty($sortorder)) $sortorder='DESC'; +if (empty($sortfield)) $sortfield = 'rowid'; +if (empty($sortorder)) $sortorder = 'DESC'; $block_static = new BlockedLog($db); @@ -78,7 +78,7 @@ $result = restrictedArea($user, 'blockedlog', 0, ''); */ // 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_fk_user = ''; $search_start = -1; @@ -87,8 +87,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_ref = ''; $search_amount = ''; $search_showonlyerrors = 0; - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if ($action === 'downloadblockchain') { @@ -98,7 +98,7 @@ if ($action === 'downloadblockchain') { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + header("Content-disposition: attachment; filename=\"".$auth->signature.".certif\""); echo $bc; @@ -106,26 +106,26 @@ if ($action === 'downloadblockchain') { } elseif (GETPOST('downloadcsv', 'alpha')) { $error = 0; - $previoushash=''; - $firstid=''; + $previoushash = ''; + $firstid = ''; - if (! $error) + if (!$error) { // Get ID of first line $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sql .= " WHERE entity = ".$conf->entity; if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):1); - $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):12); - $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; + $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1); + $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12); + $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } - $sql.= " ORDER BY rowid ASC"; // Required so we get the first one - $sql.= $db->plimit(1); + $sql .= " ORDER BY rowid ASC"; // Required so we get the first one + $sql .= $db->plimit(1); $res = $db->query($sql); - if($res) + if ($res) { // Make the first fetch to get first line $obj = $db->fetch_object($res); @@ -147,26 +147,26 @@ if ($action === 'downloadblockchain') { } } - if (! $error) + if (!$error) { // Now restart request with all data = no limit(1) in sql request $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sql .= " WHERE entity = ".$conf->entity; if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0) { - $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):1); - $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int')?GETPOST('monthtoexport', 'int'):12); - $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; + $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1); + $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12); + $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'"; } - $sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature() + $sql .= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature() $res = $db->query($sql); - if($res) + if ($res) { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport', 'int')>0 ? GETPOST('yeartoexport', 'int').(GETPOST('monthtoexport', 'int')>0?sprintf("%02d", GETPOST('monthtoexport', 'int')):'').'-':'').$previoushash. ".csv\""); + header("Content-disposition: attachment; filename=\"unalterable-log-archive-".$dolibarr_main_db_name."-".(GETPOST('yeartoexport', 'int') > 0 ? GETPOST('yeartoexport', 'int').(GETPOST('monthtoexport', 'int') > 0 ?sprintf("%02d", GETPOST('monthtoexport', 'int')) : '').'-' : '').$previoushash.".csv\""); print $langs->transnoentities('Id') .';'.$langs->transnoentities('Date') @@ -204,7 +204,7 @@ if ($action === 'downloadblockchain') { $block_static->signature = $obj->signature; $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data); - $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it + $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it if ($checksignature) { @@ -219,9 +219,9 @@ if ($action === 'downloadblockchain') { $loweridinerror = $obj->rowid; } - if ($i==0) + if ($i == 0) { - $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote?' - '.$statusofrecordnote:''); + $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote ? ' - '.$statusofrecordnote : ''); } print $obj->rowid .';'.$obj->date_creation @@ -258,15 +258,15 @@ if ($action === 'downloadblockchain') { * View */ -$form=new Form($db); +$form = new Form($db); if (GETPOST('withtab', 'alpha')) { - $title=$langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'); + $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'); } else { - $title=$langs->trans("BrowseBlockedLog"); + $title = $langs->trans("BrowseBlockedLog"); } llxHeader('', $langs->trans("BrowseBlockedLog")); @@ -274,7 +274,7 @@ llxHeader('', $langs->trans("BrowseBlockedLog")); $MAXLINES = 10000; $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code); -if (! is_array($blocks)) +if (!is_array($blocks)) { if ($blocks == -2) { @@ -287,17 +287,17 @@ if (! is_array($blocks)) } } -$linkback=''; +$linkback = ''; if (GETPOST('withtab', 'alpha')) { - $linkback=''.$langs->trans("BackToModuleList").''; + $linkback = ''.$langs->trans("BackToModuleList").''; } print load_fiche_titre($title, $linkback); if (GETPOST('withtab', 'alpha')) { - $head=blockedlogadmin_prepare_head(); + $head = blockedlogadmin_prepare_head(); dol_fiche_head($head, 'fingerprints', '', -1); } @@ -305,19 +305,19 @@ print ''.$langs->trans("Fingerprint print '
'; -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user); -if ($search_startyear > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear', 'int')); -if ($search_startmonth > 0) $param.='&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int')); -if ($search_startday > 0) $param.='&search_startday='.urlencode(GETPOST('search_startday', 'int')); -if ($search_endyear > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear', 'int')); -if ($search_endmonth > 0) $param.='&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int')); -if ($search_endday > 0) $param.='&search_endday='.urlencode(GETPOST('search_endday', 'int')); -if ($search_showonlyerrors > 0) $param.='&search_showonlyerrors='.urlencode($search_showonlyerrors); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); -if (GETPOST('withtab', 'alpha')) $param.='&withtab='.urlencode(GETPOST('withtab', 'alpha')); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user); +if ($search_startyear > 0) $param .= '&search_startyear='.urlencode(GETPOST('search_startyear', 'int')); +if ($search_startmonth > 0) $param .= '&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int')); +if ($search_startday > 0) $param .= '&search_startday='.urlencode(GETPOST('search_startday', 'int')); +if ($search_endyear > 0) $param .= '&search_endyear='.urlencode(GETPOST('search_endyear', 'int')); +if ($search_endmonth > 0) $param .= '&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int')); +if ($search_endday > 0) $param .= '&search_endday='.urlencode(GETPOST('search_endday', 'int')); +if ($search_showonlyerrors > 0) $param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if (GETPOST('withtab', 'alpha')) $param .= '&withtab='.urlencode(GETPOST('withtab', 'alpha')); // Add $param from extra fields //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -326,30 +326,30 @@ print ''; print $langs->trans("RestrictYearToExport").': '; -$smonth=GETPOST('monthtoexport', 'int'); +$smonth = GETPOST('monthtoexport', 'int'); // Month -$retstring=''; -$retstring.=''; +$retstring .= ''; +for ($month = 1; $month <= 12; $month++) { - $retstring.='"; + $retstring .= '"; } -$retstring.=""; +$retstring .= ""; print $retstring; print ''; print ''; print ''; -if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').''; +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').''; print '

'; print ''; print '
'; -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table if ($optioncss != '') print ''; print ''; @@ -405,7 +405,7 @@ print ''; // Status print ''; -$array=array("1"=>$langs->trans("OnlyNonValid")); +$array = array("1"=>$langs->trans("OnlyNonValid")); print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1); print ''; @@ -414,7 +414,7 @@ print ''; // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; @@ -435,7 +435,7 @@ print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="c print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n"; print ''; -if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { +if (!empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { // This is version that is faster but require more memory and report errors that are outside the filter range // TODO Make a full scan of table in reverse order of id of $block, so we can use the parameter $previoushash into checkSignature to save requests @@ -444,17 +444,17 @@ if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { else { // This is version that optimize the memory (but will not report errors that are outside the filter range) - $loweridinerror=0; - $checkresult=array(); + $loweridinerror = 0; + $checkresult = array(); if (is_array($blocks)) { - foreach($blocks as &$block) + foreach ($blocks as &$block) { - $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various - $checkresult[$block->id]=$checksignature; // false if error - if (! $checksignature) + $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various + $checkresult[$block->id] = $checksignature; // false if error + if (!$checksignature) { - if (empty($loweridinerror)) $loweridinerror=$block->id; + if (empty($loweridinerror)) $loweridinerror = $block->id; else $loweridinerror = min($loweridinerror, $block->id); } } @@ -463,12 +463,12 @@ else if (is_array($blocks)) { - foreach($blocks as &$block) + foreach ($blocks as &$block) { $object_link = $block->getObjectLink(); //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) - if (empty($search_showonlyerrors) || ! $checkresult[$block->id]) + if (empty($search_showonlyerrors) || !$checkresult[$block->id]) { print ''; @@ -506,7 +506,7 @@ if (is_array($blocks)) // Status print ''; - if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error + if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4'); else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8'); @@ -520,13 +520,13 @@ if (is_array($blocks)) // Note print ''; - if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error + if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo')); } - if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { - print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); + if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { + print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black')); } print ''; @@ -572,7 +572,7 @@ jQuery(document).ready(function () { '."\n"; -if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { ?> '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), 'enable'=>$langs->trans("Enable"), 'disable'=>$langs->trans("Disable"), ); if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 6b629fd2852..d21d82b5ca9 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -63,16 +63,16 @@ class Boms extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->bom->read) { + if (!DolibarrApiAccess::$user->rights->bom->read) { throw new RestException(401); } $result = $this->bom->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -103,27 +103,27 @@ class Boms extends DolibarrApi $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; - $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= " WHERE 1 = 1"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= " WHERE 1 = 1"; // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($restrictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; - if ($restrictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity('bom').')'; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($restrictonsocid && $socid) $sql .= " AND t.fk_soc = ".$socid; + if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($restrictonsocid && $search_sale > 0) { @@ -131,23 +131,23 @@ class Boms extends DolibarrApi } if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -168,7 +168,7 @@ class Boms extends DolibarrApi else { throw new RestException(503, 'Error when retrieve bom list'); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No bom found'); } return $obj_ret; @@ -182,16 +182,16 @@ class Boms extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->bom->write) { + if (!DolibarrApiAccess::$user->rights->bom->write) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->bom->$field = $value; } - if( ! $this->bom->create(DolibarrApiAccess::$user)) { + if (!$this->bom->create(DolibarrApiAccess::$user)) { throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } return $this->bom->id; @@ -207,25 +207,25 @@ class Boms extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->bom->write) { + if (!DolibarrApiAccess::$user->rights->bom->write) { throw new RestException(401); } $result = $this->bom->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->bom->$field = $value; } - if($this->bom->update($id, DolibarrApiAccess::$user) > 0) + if ($this->bom->update($id, DolibarrApiAccess::$user) > 0) { return $this->get($id); } @@ -243,19 +243,19 @@ class Boms extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->bom->delete) { + if (!DolibarrApiAccess::$user->rights->bom->delete) { throw new RestException(401); } $result = $this->bom->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'BOM not found'); } - if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { + if (!DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $this->bom->delete(DolibarrApiAccess::$user)) + if (!$this->bom->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error); } @@ -318,9 +318,9 @@ class Boms extends DolibarrApi unset($object->location_incoterms); // If object has lines, remove $db property - if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { $nboflines = count($object->lines); - for ($i=0; $i < $nboflines; $i++) + for ($i = 0; $i < $nboflines; $i++) { $this->_cleanObjectDatas($object->lines[$i]); @@ -344,7 +344,7 @@ class Boms extends DolibarrApi { $myobject = array(); foreach ($this->bom->fields as $field => $propfield) { - if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field + if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $myobject[$field] = $data[$field]; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index c2779429ebc..a9ed7ee3a00 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1009,7 +1009,7 @@ class BOM extends CommonObject */ public function calculateCosts() { - include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $this->unit_cost = 0; $this->total_cost = 0; diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 7da2c768b7f..92f43ec3fce 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -90,19 +90,19 @@ function bomPrepareHead($object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bom->dir_output."/bom/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 66bcf0cece5..be7eb3e775f 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -130,7 +130,7 @@ print ''; $coldisplay++; print ''; -print ''; +print ''; print ''; $coldisplay++; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index c8899603f58..36862e48708 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -52,11 +52,11 @@ $objectline = new BOMLine($this->db); print "\n"; -$coldisplay=0; +$coldisplay = 0; print ''; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''.($i+1).''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''.($i + 1).''; $coldisplay++; } @@ -82,8 +82,8 @@ if ($line->fk_product > 0) { if (is_object($hookmanager)) { $fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line); - $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); - $reshook=$hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action); + $parameters = array('line'=>$line, 'fk_parent_line'=>$fk_parent_line, 'var'=>$var, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer); + $reshook = $hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action); } print ''; @@ -104,7 +104,7 @@ if (($line->info_bits & 2) != 2) { // 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;"')." "; - print ''; + print ''; } print ''; @@ -117,20 +117,20 @@ if ($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; -print 'qty_frozen?' checked="checked"':'')).'>'; +print 'qty_frozen ? ' checked="checked"' : '')).'>'; print ''; $coldisplay++; -print 'disable_stock_change?' checked="checked"':'')).'">'; +print 'disable_stock_change ? ' checked="checked"' : '')).'">'; print ''; $coldisplay++; print ''; print ''; -$coldisplay+=$colspan; +$coldisplay += $colspan; print ''; -$coldisplay+=$colspan; +$coldisplay += $colspan; print ''; print '
'; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index ce440dbaab6..b6197342136 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -34,7 +34,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; @@ -46,7 +46,7 @@ print "\n"; print ''; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; // Description print ''.$langs->trans('Description').''; @@ -71,7 +71,7 @@ print ''.$form->textwithpicto($langs->trans( // Cost print ''.$langs->trans('CostPrice').''; -print ''; // No width to allow autodim +print ''; // No width to allow autodim print ''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1419136a2e8..667c66848ae 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -95,7 +95,7 @@ echo $line->qty_frozen ? yn($line->qty_frozen) : ''; print ''; print ''; $coldisplay++; -echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price +echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; print ''; @@ -108,10 +108,10 @@ $coldisplay++; echo price($line->total_cost); print ''; -if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { +if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { print ''; $coldisplay++; - if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { + if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { print 'id.'#line_'.$line->id.'">'.img_edit().''; } diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index b2c7d227b38..bc0c0c37fc2 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -31,16 +31,16 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); if ($action == 'setvalue') { $showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha'); $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -59,7 +59,7 @@ if ($action == 'setvalue') llxHeader(); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BookmarkSetup"), $linkback, 'title_setup'); print $langs->trans("BookmarkDesc")."
\n"; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 699065520da..46e9ca315a5 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -60,7 +60,7 @@ function printDropdownBookmarksList() } $searchForm = ''."\n"; - $searchForm .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)?'onsubmit="return false"':'').'>'; + $searchForm .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? 'onsubmit="return false"' : '').'>'; $searchForm .= ''; @@ -106,9 +106,9 @@ function printDropdownBookmarksList() $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">'; $searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...'; // Url to go on create new bookmark page - if (! empty($user->rights->bookmark->creer)) + if (!empty($user->rights->bookmark->creer)) { - $urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); + $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); $searchForm .= ''; } @@ -131,10 +131,10 @@ function printDropdownBookmarksList() $searchForm .= ''; // Generate the return string - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $html = $searchForm; - $html.=' + $html .= ' '; print ''; - print ''; + print ''; print ' '; print ''; print ''; diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php index 28607ecca26..d728ac2a71b 100644 --- a/htdocs/compta/bank/bilan.php +++ b/htdocs/compta/bank/bilan.php @@ -44,10 +44,10 @@ function valeur($sql) $valeur = 0; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $valeur = $obj->amount; $db->free($resql); } diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index a4c57a60fdd..042117808d5 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -31,15 +31,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories')); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque'); /* * View */ -$companystatic=new Societe($db); +$companystatic = new Societe($db); llxHeader(); @@ -55,14 +55,14 @@ print ''.$langs->trans("Average").''; print "\n"; $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid "; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; -$sql.= ", ".MAIN_DB_PREFIX."bank_class as l"; -$sql.= ", ".MAIN_DB_PREFIX."bank as d"; -$sql.= " WHERE c.entity = ".$conf->entity; -$sql.= " AND c.rowid = l.fk_categ"; -$sql.= " AND d.rowid = l.lineid"; -$sql.= " GROUP BY c.label, c.rowid"; -$sql.= " ORDER BY c.label"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; +$sql .= ", ".MAIN_DB_PREFIX."bank_class as l"; +$sql .= ", ".MAIN_DB_PREFIX."bank as d"; +$sql .= " WHERE c.entity = ".$conf->entity; +$sql .= " AND c.rowid = l.fk_categ"; +$sql .= " AND d.rowid = l.lineid"; +$sql .= " GROUP BY c.label, c.rowid"; +$sql .= " ORDER BY c.label"; $result = $db->query($sql); if ($result) @@ -88,7 +88,7 @@ if ($result) print ''.$langs->trans("Total").''; print ''.price($total).''; - print ''.price($totalnb?price2num($total / $totalnb, 'MT'):0).''; + print ''.price($totalnb ?price2num($total / $totalnb, 'MT') : 0).''; } else { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 60d7c4f2463..cba83d8f015 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1188,34 +1188,34 @@ class Account extends CommonObject // phpcs:enable global $conf, $langs; - if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT b.rowid, b.datev as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.rappro=0"; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.rappro=0"; + $sql .= " AND b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql .= " AND clos = 0"; + if ($filteraccountid) $sql .= " AND ba.rowid = ".$filteraccountid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("banks"); - $now=dol_now(); + $now = dol_now(); require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; $response = new WorkboardResponse(); - $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; - $response->label=$langs->trans("TransactionsToConciliate"); + $response->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("TransactionsToConciliate"); $response->labelShort = $langs->trans("TransactionsToConciliateShort"); - $response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank'; - $response->img=img_object('', "payment"); + $response->url = DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank'; + $response->img = img_object('', "payment"); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) { @@ -1244,30 +1244,30 @@ class Account extends CommonObject // phpcs:enable global $user; - if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe $sql = "SELECT count(b.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable - $sql.= " AND clos = 0"; - if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable + $sql .= " AND clos = 0"; + if ($filteraccountid) $sql .= " AND ba.rowid = ".$filteraccountid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["banklines"]=$obj->nb; + $this->nb["banklines"] = $obj->nb; } $this->db->free($resql); } else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 1272cfcad85..2fb97ff949c 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -66,32 +66,32 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')'; + $sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')'; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $this->db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -108,7 +108,7 @@ class BankAccounts extends DolibarrApi } } } else { - throw new RestException(503, 'Error when retrieving list of accounts: ' . $this->db->lasterror()); + throw new RestException(503, 'Error when retrieving list of accounts: '.$this->db->lasterror()); } return $list; @@ -124,13 +124,13 @@ class BankAccounts extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -145,7 +145,7 @@ class BankAccounts extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } // Check mandatory fields @@ -190,7 +190,7 @@ class BankAccounts extends DolibarrApi */ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } @@ -235,14 +235,14 @@ class BankAccounts extends DolibarrApi $user = DolibarrApiAccess::$user; // By default, electronic transfert from bank to bank - $typefrom='PRE'; - $typeto='VIR'; + $typefrom = 'PRE'; + $typeto = 'VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfer of change - $typefrom='LIQ'; - $typeto='LIQ'; + $typefrom = 'LIQ'; + $typeto = 'LIQ'; } /** @@ -250,7 +250,7 @@ class BankAccounts extends DolibarrApi */ if (!$error) { - $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1*price2num($amount), '', '', $user); + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user); } if (!($bank_line_id_from > 0)) { $error++; @@ -312,13 +312,13 @@ class BankAccounts extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -345,12 +345,12 @@ class BankAccounts extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -378,7 +378,7 @@ class BankAccounts extends DolibarrApi { $account = array(); foreach (BankAccounts::$FIELDS as $field) { - if (! isset($data[$field])) + if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $account[$field] = $data[$field]; } @@ -417,13 +417,13 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (! DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -433,12 +433,12 @@ class BankAccounts extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql .= " ORDER BY rowid"; @@ -455,7 +455,7 @@ class BankAccounts extends DolibarrApi } } } else { - throw new RestException(503, 'Error when retrieving list of account lines: ' . $accountLine->error); + throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); } return $list; @@ -479,13 +479,13 @@ class BankAccounts extends DolibarrApi */ public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') { - if (! DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } @@ -500,7 +500,7 @@ class BankAccounts extends DolibarrApi $cheque_writer, $cheque_bank ); if ($result < 0) { - throw new RestException(503, 'Error when adding line to account: ' . $account->error); + throw new RestException(503, 'Error when adding line to account: '.$account->error); } return $result; } @@ -520,25 +520,25 @@ class BankAccounts extends DolibarrApi */ public function addLink($id, $line_id, $url_id, $url, $label, $type) { - if (! DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); } $account = new Account($this->db); $result = $account->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account not found'); } $accountLine = new AccountLine($this->db); $result = $accountLine->fetch($line_id); - if (! $result) { + if (!$result) { throw new RestException(404, 'account line not found'); } $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); if ($result < 0) { - throw new RestException(503, 'Error when adding link to account line: ' . $account->error); + throw new RestException(503, 'Error when adding link to account line: '.$account->error); } return $result; } diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 92e16211ce0..c7e86e51cfb 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -33,7 +33,7 @@ class BankCateg // extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='generic'; + public $picto = 'generic'; /** * @var int ID @@ -211,10 +211,10 @@ class BankCateg // extends CommonObject $this->db->begin(); // Delete link between tag and bank account - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql.= " WHERE fk_categorie = ".$this->id; + $sql .= " WHERE fk_categorie = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -225,10 +225,10 @@ class BankCateg // extends CommonObject } // Delete link between tag and bank lines - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; - $sql.= " WHERE fk_categ = ".$this->id; + $sql .= " WHERE fk_categ = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -239,7 +239,7 @@ class BankCateg // extends CommonObject } // Delete bank categ - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; $sql .= " WHERE rowid=".$this->id; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 58e01ec2f28..6af394ad4b4 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -34,12 +34,12 @@ class PaymentVarious extends CommonObject /** * @var string ID to identify managed object */ - public $element='variouspayment'; + public $element = 'variouspayment'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='payment_various'; + public $table_element = 'payment_various'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -118,12 +118,12 @@ class PaymentVarious extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->amount = trim($this->amount); + $this->label = trim($this->label); + $this->note = trim($this->note); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_modif = (int) $this->fk_user_modif; @@ -132,40 +132,40 @@ class PaymentVarious extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; - if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',"; - $sql.= " datep='".$this->db->idate($this->datep)."',"; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " sens=".(int) $this->sens.","; - $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_typepayment=".(int) $this->fk_typepayment.","; - $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; - $sql.= " subledger_account='".$this->db->escape($this->subledger_account)."',"; - $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").","; - $sql.= " fk_user_author=".(int) $this->fk_user_author.","; - $sql.= " fk_user_modif=".(int) $this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + if ($this->tms) $sql .= " tms='".$this->db->idate($this->tms)."',"; + $sql .= " datep='".$this->db->idate($this->datep)."',"; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " sens=".(int) $this->sens.","; + $sql .= " amount=".price2num($this->amount).","; + $sql .= " fk_typepayment=".(int) $this->fk_typepayment.","; + $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " note='".$this->db->escape($this->note)."',"; + $sql .= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; + $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; + $sql .= " fk_projet='".$this->db->escape($this->fk_project)."',"; + $sql .= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank : "null").","; + $sql .= " fk_user_author=".(int) $this->fk_user_author.","; + $sql .= " fk_user_modif=".(int) $this->fk_user_modif; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -189,31 +189,31 @@ class PaymentVarious extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " v.rowid,"; - $sql.= " v.tms,"; - $sql.= " v.datep,"; - $sql.= " v.datev,"; - $sql.= " v.sens,"; - $sql.= " v.amount,"; - $sql.= " v.fk_typepayment,"; - $sql.= " v.num_payment,"; - $sql.= " v.label,"; - $sql.= " v.note,"; - $sql.= " v.accountancy_code,"; - $sql.= " v.subledger_account,"; - $sql.= " v.fk_projet as fk_project,"; - $sql.= " v.fk_bank,"; - $sql.= " v.fk_user_author,"; - $sql.= " v.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; - $sql.= " WHERE v.rowid = ".$id; + $sql .= " v.rowid,"; + $sql .= " v.tms,"; + $sql .= " v.datep,"; + $sql .= " v.datev,"; + $sql .= " v.sens,"; + $sql .= " v.amount,"; + $sql .= " v.fk_typepayment,"; + $sql .= " v.num_payment,"; + $sql .= " v.label,"; + $sql .= " v.note,"; + $sql .= " v.accountancy_code,"; + $sql .= " v.subledger_account,"; + $sql .= " v.fk_projet as fk_project,"; + $sql .= " v.fk_bank,"; + $sql .= " v.fk_user_author,"; + $sql .= " v.fk_user_modif,"; + $sql .= " b.fk_account,"; + $sql .= " b.fk_type,"; + $sql .= " b.rappro"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; + $sql .= " WHERE v.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -247,7 +247,7 @@ class PaymentVarious extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -263,22 +263,22 @@ class PaymentVarious extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_DELETE', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_DELETE', $user); if ($result < 0) return -1; // End call triggers $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_various"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -295,20 +295,20 @@ class PaymentVarious extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=''; - $this->datep=''; - $this->datev=''; - $this->sens=''; - $this->amount=''; - $this->label=''; - $this->accountancy_code=''; - $this->subledger_account=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_author=''; - $this->fk_user_modif=''; + $this->tms = ''; + $this->datep = ''; + $this->datev = ''; + $this->sens = ''; + $this->amount = ''; + $this->label = ''; + $this->accountancy_code = ''; + $this->subledger_account = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_author = ''; + $this->fk_user_modif = ''; } /** @@ -319,38 +319,38 @@ class PaymentVarious extends CommonObject */ public function create($user) { - global $conf,$langs; + global $conf, $langs; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->amount=price2num(trim($this->amount)); - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); + $this->note = trim($this->note); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_modif = (int) $this->fk_user_modif; // Check parameters - if (! $this->label) + if (!$this->label) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } if ($this->amount < 0 || $this->amount == '') { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -6; } - if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -7; } @@ -358,39 +358,39 @@ class PaymentVarious extends CommonObject // Insert into llx_payment_various $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_various ("; - $sql.= " datep"; - $sql.= ", datev"; - $sql.= ", sens"; - $sql.= ", amount"; - $sql.= ", fk_typepayment"; - $sql.= ", num_payment"; - if ($this->note) $sql.= ", note"; - $sql.= ", label"; - $sql.= ", accountancy_code"; - $sql.= ", subledger_account"; - $sql.= ", fk_projet"; - $sql.= ", fk_user_author"; - $sql.= ", datec"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= "'".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->db->escape($this->sens)."'"; - $sql.= ", ".price2num($this->amount); - $sql.= ", '".$this->db->escape($this->type_payment)."'"; - $sql.= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; - $sql.= ", '".$this->db->escape($this->subledger_account)."'"; - $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); - $sql.= ", ".$user->id; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + $sql .= " datep"; + $sql .= ", datev"; + $sql .= ", sens"; + $sql .= ", amount"; + $sql .= ", fk_typepayment"; + $sql .= ", num_payment"; + if ($this->note) $sql .= ", note"; + $sql .= ", label"; + $sql .= ", accountancy_code"; + $sql .= ", subledger_account"; + $sql .= ", fk_projet"; + $sql .= ", fk_user_author"; + $sql .= ", datec"; + $sql .= ", fk_bank"; + $sql .= ", entity"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= "'".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", '".$this->db->escape($this->sens)."'"; + $sql .= ", ".price2num($this->amount); + $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql .= ", '".$this->db->escape($this->subledger_account)."'"; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", NULL"; + $sql .= ", ".$conf->entity; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -401,19 +401,19 @@ class PaymentVarious extends CommonObject if ($this->id > 0) { - if (! empty($conf->banque->enabled) && ! empty($this->amount)) + if (!empty($conf->banque->enabled) && !empty($this->amount)) { // Insert into llx_bank require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); + $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); // Insert payment into llx_bank // Add link 'payment_various' in bank_url between payment and bank transaction - $sign=1; - if ($this->sens == '0') $sign=-1; + $sign = 1; + if ($this->sens == '0') $sign = -1; $bank_line_id = $acc->addline( $this->datep, @@ -433,38 +433,38 @@ class PaymentVarious extends CommonObject } else { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } - if (! $error) + if (!$error) { // Add link 'payment_various' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='; + $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(VariousPayment)", "payment_various"); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(VariousPayment)", "payment_various"); if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } if ($result <= 0) { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } // Call trigger - $result=$this->call_trigger('PAYMENT_VARIOUS_CREATE', $user); + $result = $this->call_trigger('PAYMENT_VARIOUS_CREATE', $user); if ($result < 0) $error++; // End call triggers } else $error++; - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -477,7 +477,7 @@ class PaymentVarious extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -494,7 +494,7 @@ class PaymentVarious extends CommonObject { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { @@ -542,27 +542,27 @@ class PaymentVarious extends CommonObject } elseif ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } elseif ($mode == 4) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + if ($status == 0 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { - if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - elseif ($status==2 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + if ($status == 0 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); + elseif ($status == 2 && !empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); } } @@ -581,34 +581,34 @@ class PaymentVarious extends CommonObject global $db, $conf, $langs, $hookmanager; global $langs; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - $label=''.$langs->trans("ShowVariousPayment").''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("ShowVariousPayment").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -617,22 +617,22 @@ class PaymentVarious extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); global $action; $hookmanager->initHooks(array('variouspayment')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -648,8 +648,8 @@ class PaymentVarious extends CommonObject public function info($id) { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; - $sql.= ' WHERE v.rowid = '.$id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; + $sql .= ' WHERE v.rowid = '.$id; dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 022e1ceea5a..9fd2207f3ec 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -67,7 +67,7 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); @@ -97,7 +97,7 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . '/' . $object->ref; + $upload_dir = $conf->bank->dir_output.'/'.$object->ref; // Onglets $head = bank_prepare_head($object); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index ccf677fa2b8..347353be84f 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -257,7 +257,7 @@ else $show1 = $px1->show(); $px1 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; @@ -395,7 +395,7 @@ else $show2 = $px2->show(); $px2 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; @@ -509,7 +509,7 @@ else $show3 = $px3->show(); $px3 = null; - $graph_datas =null; + $graph_datas = null; $datas = null; $datamin = null; $dataall = null; diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index 0ed5b4ff003..abab3b4ff9c 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -43,7 +43,7 @@ $object->fetch($id); $object->info($id); -$h=0; +$h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id; $head[$h][1] = $langs->trans("Card"); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index d98a37594b0..515759547a6 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -35,27 +35,27 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other')); -if (! empty($conf->adherent->enabled)) $langs->load("members"); -if (! empty($conf->don->enabled)) $langs->load("donations"); -if (! empty($conf->loan->enabled)) $langs->load("loan"); -if (! empty($conf->salaries->enabled)) $langs->load("salaries"); +if (!empty($conf->adherent->enabled)) $langs->load("members"); +if (!empty($conf->don->enabled)) $langs->load("donations"); +if (!empty($conf->loan->enabled)) $langs->load("loan"); +if (!empty($conf->salaries->enabled)) $langs->load("salaries"); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$rowid=GETPOST("rowid", 'int'); -$orig_account=GETPOST("orig_account"); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$rowid = GETPOST("rowid", 'int'); +$orig_account = GETPOST("orig_account"); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); -if (! $user->rights->banque->lire && ! $user->rights->banque->consolidate) accessforbidden(); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); +if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessforbidden(); /* @@ -92,10 +92,10 @@ if ($user->rights->banque->consolidate && $action == 'donext') if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) { - $cat1=GETPOST("cat1", 'int'); + $cat1 = GETPOST("cat1", 'int'); if (!empty($rowid) && !empty($cat1)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1; - if (! $db->query($sql)) + if (!$db->query($sql)) { dol_print_error($db); } @@ -108,7 +108,7 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban if ($user->rights->banque->modifier && $action == "update") { - $error=0; + $error = 0; $acline = new AccountLine($db); $acline->fetch($rowid); @@ -117,7 +117,7 @@ if ($user->rights->banque->modifier && $action == "update") $acsource->fetch($id); $actarget = new Account($db); - if (GETPOST('accountid', 'int') > 0 && ! $acline->rappro && ! $acline->getVentilExportCompta()) // We ask to change bank account + if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) // We ask to change bank account { $actarget->fetch(GETPOST('accountid', 'int')); } @@ -132,52 +132,52 @@ if ($user->rights->banque->modifier && $action == "update") $error++; } - if (! $error) + if (!$error) { $db->begin(); $amount = price2num($_POST['amount']); $dateop = dol_mktime(12, 0, 0, $_POST["dateomonth"], $_POST["dateoday"], $_POST["dateoyear"]); - $dateval= dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $dateval = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET "; + $sql .= " SET "; // Always opened - if (isset($_POST['value'])) $sql.=" fk_type='".$db->escape($_POST['value'])."',"; - if (isset($_POST['num_chq'])) $sql.=" num_chq='".$db->escape($_POST["num_chq"])."',"; - if (isset($_POST['banque'])) $sql.=" banque='".$db->escape($_POST["banque"])."',"; - if (isset($_POST['emetteur'])) $sql.=" emetteur='".$db->escape($_POST["emetteur"])."',"; + if (isset($_POST['value'])) $sql .= " fk_type='".$db->escape($_POST['value'])."',"; + if (isset($_POST['num_chq'])) $sql .= " num_chq='".$db->escape($_POST["num_chq"])."',"; + if (isset($_POST['banque'])) $sql .= " banque='".$db->escape($_POST["banque"])."',"; + if (isset($_POST['emetteur'])) $sql .= " emetteur='".$db->escape($_POST["emetteur"])."',"; // Blocked when conciliated - if (! $acline->rappro) + if (!$acline->rappro) { - if (isset($_POST['label'])) $sql.=" label='".$db->escape($_POST["label"])."',"; - if (isset($_POST['amount'])) $sql.=" amount='".$amount."',"; - if (isset($_POST['dateomonth'])) $sql.=" dateo = '".$db->idate($dateop)."',"; - if (isset($_POST['datevmonth'])) $sql.=" datev = '".$db->idate($dateval)."',"; + if (isset($_POST['label'])) $sql .= " label='".$db->escape($_POST["label"])."',"; + if (isset($_POST['amount'])) $sql .= " amount='".$amount."',"; + if (isset($_POST['dateomonth'])) $sql .= " dateo = '".$db->idate($dateop)."',"; + if (isset($_POST['datevmonth'])) $sql .= " datev = '".$db->idate($dateval)."',"; } - $sql.= " fk_account = ".$actarget->id; - $sql.= " WHERE rowid = ".$acline->id; + $sql .= " fk_account = ".$actarget->id; + $sql .= " WHERE rowid = ".$acline->id; $result = $db->query($sql); - if (! $result) + if (!$result) { $error++; } - if (! $error) + if (!$error) { - $arrayofcategs=GETPOST('custcats', 'array'); + $arrayofcategs = GETPOST('custcats', 'array'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; dol_print_error($db); } if (count($arrayofcategs)) { - foreach($arrayofcategs as $val) + foreach ($arrayofcategs as $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; dol_print_error($db); @@ -187,7 +187,7 @@ if ($user->rights->banque->modifier && $action == "update") } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); @@ -203,8 +203,8 @@ if ($user->rights->banque->modifier && $action == "update") // Reconcile if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) { - $num_rel=trim($_POST["num_rel"]); - $rappro=$_POST['reconciled']?1:0; + $num_rel = trim($_POST["num_rel"]); + $rappro = $_POST['reconciled'] ? 1 : 0; // Check parameters if ($rappro && empty($num_rel)) @@ -213,15 +213,15 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $error++; } - if (! $error) + if (!$error) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql.= " SET num_releve=".($num_rel?"'".$num_rel."'":"null"); - if (empty($num_rel)) $sql.= ", rappro = 0"; - else $sql.=", rappro = ".$rappro; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " SET num_releve=".($num_rel ? "'".$num_rel."'" : "null"); + if (empty($num_rel)) $sql .= ", rappro = 0"; + else $sql .= ", rappro = ".$rappro; + $sql .= " WHERE rowid = ".$rowid; dol_syslog("line.php", LOG_DEBUG); $result = $db->query($sql); @@ -267,11 +267,11 @@ $tabs = array( $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,"; -$sql.= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; -$sql.= " b.emetteur,b.banque"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= " WHERE rowid=".$rowid; -$sql.= " ORDER BY dateo ASC"; +$sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; +$sql .= " b.emetteur,b.banque"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= " WHERE rowid=".$rowid; +$sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { @@ -282,14 +282,14 @@ if ($result) $total = $total + $objp->amount; - $acct=new Account($db); + $acct = new Account($db); $acct->fetch($objp->fk_account); $account = $acct->id; $bankline = new AccountLine($db); $bankline->fetch($rowid, $ref); - $links=$acct->get_url($rowid); + $links = $acct->get_url($rowid); $bankline->load_previous_next_ref('', 'rowid'); // Confirmations @@ -321,7 +321,7 @@ if ($result) // Bank account print ''.$langs->trans("Account").''; print ''; - if (! $objp->rappro && ! $bankline->getVentilExportCompta()) + if (!$objp->rappro && !$bankline->getVentilExportCompta()) { $form->select_comptes($acct->id, 'accountid', 0, '', 0); } @@ -337,12 +337,12 @@ if ($result) { print ''.$langs->trans("Links").''; print ''; - foreach($links as $key=>$val) + foreach ($links as $key=>$val) { if ($key) print '
'; - if ($links[$key]['type']=='payment') { + if ($links[$key]['type'] == 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $paymenttmp=new Paiement($db); + $paymenttmp = new Paiement($db); $paymenttmp->fetch($links[$key]['url_id']); $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; /*print ''; @@ -351,9 +351,9 @@ if ($result) print '';*/ print $paymenttmp->getNomUrl(1); } - elseif ($links[$key]['type']=='payment_supplier') { + elseif ($links[$key]['type'] == 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; - $paymenttmp=new PaiementFourn($db); + $paymenttmp = new PaiementFourn($db); $paymenttmp->fetch($links[$key]['url_id']); $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; /*print ''; @@ -362,72 +362,72 @@ if ($result) print '';*/ print $paymenttmp->getNomUrl(1); } - elseif ($links[$key]['type']=='company') { - $societe=new Societe($db); + elseif ($links[$key]['type'] == 'company') { + $societe = new Societe($db); $societe->fetch($links[$key]['url_id']); print $societe->getNomUrl(1); } - elseif ($links[$key]['type']=='sc') { + elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('ShowSocialContribution'), 'bill').' '; - print $langs->trans("SocialContribution").($links[$key]['label']?' - '.$links[$key]['label']:''); + print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); print ''; } - elseif ($links[$key]['type']=='payment_sc') { + elseif ($links[$key]['type'] == 'payment_sc') { print ''; print img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("SocialContributionPayment"); print ''; } - elseif ($links[$key]['type']=='payment_vat') { + elseif ($links[$key]['type'] == 'payment_vat') { print ''; print img_object($langs->trans('ShowVAT'), 'payment').' '; print $langs->trans("VATPayment"); print ''; } - elseif ($links[$key]['type']=='payment_salary') { + elseif ($links[$key]['type'] == 'payment_salary') { print ''; print img_object($langs->trans('ShowPaymentSalary'), 'payment').' '; print $langs->trans("SalaryPayment"); print ''; } - elseif ($links[$key]['type']=='payment_loan') { + elseif ($links[$key]['type'] == 'payment_loan') { print ''; print img_object($langs->trans('ShowLoanPayment'), 'payment').' '; print $langs->trans("PaymentLoan"); print ''; } - elseif ($links[$key]['type']=='loan') { + elseif ($links[$key]['type'] == 'loan') { print ''; print img_object($langs->trans('ShowLoan'), 'bill').' '; print $langs->trans("Loan"); print ''; } - elseif ($links[$key]['type']=='member') { + elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('ShowMember'), 'user').' '; print $links[$key]['label']; print ''; } - elseif ($links[$key]['type']=='payment_donation') { + elseif ($links[$key]['type'] == 'payment_donation') { print ''; print img_object($langs->trans('ShowDonation'), 'payment').' '; print $langs->trans("DonationPayment"); print ''; } - elseif ($links[$key]['type']=='banktransfert') { + elseif ($links[$key]['type'] == 'banktransfert') { print ''; print img_object($langs->trans('ShowTransaction'), 'payment').' '; print $langs->trans("TransactionOnTheOtherAccount"); print ''; } - elseif ($links[$key]['type']=='user') { + elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('ShowUser'), 'user').' '; print $langs->trans("User"); print ''; } - elseif ($links[$key]['type']=='payment_various') { + elseif ($links[$key]['type'] == 'payment_various') { print ''; print img_object($langs->trans('ShowVariousPayment'), 'payment').' '; print $langs->trans("VariousPayment"); @@ -458,7 +458,7 @@ if ($result) if ($objp->receiptid) { include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $receipt=new RemiseCheque($db); + $receipt = new RemiseCheque($db); $receipt->fetch($objp->receiptid); print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); } @@ -508,13 +508,13 @@ if ($result) { print ''; print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); - if (! $objp->rappro) + if (!$objp->rappro) { print '   '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; } print ''; } @@ -532,13 +532,13 @@ if ($result) { print ''; print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); - if (! $objp->rappro) + if (!$objp->rappro) { print '   '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; } print ''; } @@ -555,7 +555,7 @@ if ($result) if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { print ''; - print 'rappro?' disabled':'').' value="'; + print 'rappro ? ' disabled' : '').' value="'; if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant @@ -589,7 +589,7 @@ if ($result) if ($user->rights->banque->modifier) { print ''; - print 'rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); + print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); print ''; } else @@ -601,12 +601,12 @@ if ($result) print ""; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Bank line - print '' . $form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0) . ''; + print ''.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); print ""; @@ -647,12 +647,12 @@ if ($result) print ''; if ($objp->rappro) { - print $langs->trans("AccountStatement").' rappro?' disabled':'').'>'; + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; print ''; } else { - print $langs->trans("AccountStatement").' rappro?' disabled':'').'>'; + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; } if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; print ''; @@ -667,7 +667,7 @@ if ($result) if ($user->rights->banque->consolidate) { print ''; - print 'rappro?' checked="checked"':'')).'">'; + print 'rappro ? ' checked="checked"' : '')).'">'; print ''; } else diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 82cdd4e826a..c737af4a89e 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -205,9 +205,9 @@ $paymentvatstatic = new TVA($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); $remisestatic = new RemiseCheque($db); -$paymentdonationstatic=new PaymentDonation($db); -$paymentloanstatic=new PaymentLoan($db); -$paymentvariousstatic=new PaymentVarious($db); +$paymentdonationstatic = new PaymentDonation($db); +$paymentloanstatic = new PaymentLoan($db); +$paymentvariousstatic = new PaymentVarious($db); // Must be before button action $param = ''; @@ -518,28 +518,28 @@ else print ''; $newline = 0; } - elseif ($links[$key]['type']=='payment_donation') + elseif ($links[$key]['type'] == 'payment_donation') { - $paymentdonationstatic->id=$links[$key]['url_id']; - $paymentdonationstatic->ref=$langs->trans("Payment"); + $paymentdonationstatic->id = $links[$key]['url_id']; + $paymentdonationstatic->ref = $langs->trans("Payment"); print ' '.$paymentdonationstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='payment_loan') + elseif ($links[$key]['type'] == 'payment_loan') { - $paymentloanstatic->id=$links[$key]['url_id']; - $paymentloanstatic->ref=$langs->trans("Payment"); + $paymentloanstatic->id = $links[$key]['url_id']; + $paymentloanstatic->ref = $langs->trans("Payment"); print ' '.$paymentloanstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='payment_various') + elseif ($links[$key]['type'] == 'payment_various') { - $paymentvariousstatic->id=$links[$key]['url_id']; - $paymentvariousstatic->ref=$langs->trans("Payment"); + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $langs->trans("Payment"); print ' '.$paymentvariousstatic->getNomUrl(1); $newline = 0; } - elseif ($links[$key]['type']=='banktransfert') { + elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 611d2fc42b0..cb6073f1109 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "categories", "multicurrency")); -if (! $user->rights->banque->transfer) +if (!$user->rights->banque->transfer) accessforbidden(); $action = GETPOST('action', 'alpha'); @@ -51,46 +51,46 @@ if ($action == 'add') $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $label = GETPOST('label', 'alpha'); - $amount= GETPOST('amount', 'alpha'); - $amountto= GETPOST('amountto', 'alpha'); + $amount = GETPOST('amount', 'alpha'); + $amountto = GETPOST('amountto', 'alpha'); - if (! $label) + if (!$label) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors'); } - if (! $amount) + if (!$amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); } - if (! GETPOST('account_from', 'int')) + if (!GETPOST('account_from', 'int')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), null, 'errors'); } - if (! GETPOST('account_to', 'int')) + if (!GETPOST('account_to', 'int')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), null, 'errors'); } - if (! $error) + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountfrom=new Account($db); + $accountfrom = new Account($db); $accountfrom->fetch(GETPOST('account_from', 'int')); - $accountto=new Account($db); + $accountto = new Account($db); $accountto->fetch(GETPOST('account_to', 'int')); if ($accountto->currency_code == $accountfrom->currency_code) { - $amountto=$amount; + $amountto = $amount; } else { - if (! $amountto) + if (!$amountto) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors'); @@ -101,31 +101,31 @@ if ($action == 'add') { $db->begin(); - $bank_line_id_from=0; - $bank_line_id_to=0; - $result=0; + $bank_line_id_from = 0; + $bank_line_id_to = 0; + $result = 0; // By default, electronic transfert from bank to bank - $typefrom='PRE'; - $typeto='VIR'; + $typefrom = 'PRE'; + $typeto = 'VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfer of change - $typefrom='LIQ'; - $typeto='LIQ'; + $typefrom = 'LIQ'; + $typeto = 'LIQ'; } - if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user); - if (! ($bank_line_id_from > 0)) $error++; - if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user); - if (! ($bank_line_id_to > 0)) $error++; + if (!$error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1 * price2num($amount), '', '', $user); + if (!($bank_line_id_from > 0)) $error++; + if (!$error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user); + if (!($bank_line_id_to > 0)) $error++; - if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); - if (! ($result > 0)) $error++; - if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); - if (! ($result > 0)) $error++; + if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!($result > 0)) $error++; + if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!($result > 0)) $error++; - if (! $error) + if (!$error) { $mesgs = $langs->trans("TransferFromToDone", ''.$accountfrom->label."", ''.$accountto->label."", $amount, $langs->transnoentities("Currency".$conf->currency)); setEventMessages($mesgs, null, 'mesgs'); @@ -214,17 +214,17 @@ print ' '; -$form=new Form($db); +$form = new Form($db); -$account_from=''; -$account_to=''; -$label=''; -$amount=''; +$account_from = ''; +$account_to = ''; +$label = ''; +$amount = ''; if ($error) { - $account_from = GETPOST('account_from', 'int'); - $account_to = GETPOST('account_to', 'int'); + $account_from = GETPOST('account_from', 'int'); + $account_to = GETPOST('account_to', 'int'); $label = GETPOST('label', 'alpha'); $amount = GETPOST('amount', 'alpha'); } @@ -246,17 +246,17 @@ print ''.$langs->trans("TransferFrom").''.$langs->trans("TransferTo print ''.$langs->trans("AmountToOthercurrency").''; print ''; -$var=false; +$var = false; print ''; -$form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1); +$form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled) ? 0 : 1); print ""; print "\n"; -$form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1); +$form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled) ? 0 : 1); print "\n"; print ""; -print $form->selectDate((! empty($dateo)?$dateo:''), '', '', '', '', 'add'); +print $form->selectDate((!empty($dateo) ? $dateo : ''), '', '', '', '', 'add'); print "\n"; print ''; print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 6573207a117..ccd6b24c6b9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -40,37 +40,37 @@ if (!empty($conf->projet->enabled)) $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "categories")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); -$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; -$label = GETPOST("label", "alpha"); -$sens = GETPOST("sens", "int"); -$amount = price2num(GETPOST("amount", "alpha")); -$paymenttype = GETPOST("paymenttype", "int"); -$accountancy_code = GETPOST("accountancy_code", "alpha"); -$subledger_account = GETPOST("subledger_account", "alpha"); -$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); +$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; +$label = GETPOST("label", "alpha"); +$sens = GETPOST("sens", "int"); +$amount = price2num(GETPOST("amount", "alpha")); +$paymenttype = GETPOST("paymenttype", "int"); +$accountancy_code = GETPOST("accountancy_code", "alpha"); +$subledger_account = GETPOST("subledger_account", "alpha"); +$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); $object = new PaymentVarious($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('variouscard','globalcard')); +$hookmanager->initHooks(array('variouscard', 'globalcard')); /** * Actions */ -$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)) @@ -429,44 +429,44 @@ if ($id) { $alreadyaccounted = $object->getVentilExportCompta(); - $head=various_payment_prepare_head($object); + $head = various_payment_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); - $morehtmlref='
'; + $morehtmlref = '
'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->banque->modifier) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; - $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref .= '
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index f0f584ca99b..05a7d28c8c8 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -30,12 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); /* @@ -53,40 +53,40 @@ $head = various_payment_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("VariousPayment"), -1, $object->picto); -$morehtmlref='
'; +$morehtmlref = '
'; // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' : '; + $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
'; -$linkback = ''.$langs->trans("BackToList").''; +$morehtmlref .= '
'; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index a6f68b31330..70a26d231e1 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -184,7 +184,7 @@ elseif ($action == "add") $action = "view"; } } - if ($contextpage == 'takepos'){ + if ($contextpage == 'takepos') { print " '; + $out .= ''; } else { - $out.= ''; + $out .= ''; } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 40bfe965c60..65051b3c05b 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_activity extends ModeleBoxes { - public $boxcode="activity"; - public $boximg="object_bill"; - public $boxlabel='BoxGlobalActivity'; + public $boxcode = "activity"; + public $boximg = "object_bill"; + public $boxlabel = 'BoxGlobalActivity'; public $depends = array("facture"); /** @@ -60,11 +60,11 @@ class box_activity extends ModeleBoxes $this->db = $db; // FIXME: Pb into some status - $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) + $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) - $this->hidden = ! ((! empty($conf->facture->enabled) && $user->rights->facture->lire) - || (! empty($conf->commande->enabled) && $user->rights->commande->lire) - || (! empty($conf->propal->enabled) && $user->rights->propale->lire) + $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) + || (!empty($conf->commande->enabled) && $user->rights->commande->lire) + || (!empty($conf->propal->enabled) && $user->rights->propale->lire) ); } @@ -84,11 +84,11 @@ class box_activity extends ModeleBoxes $totalnb = 0; $line = 0; $cachetime = 3600; - $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; $now = dol_now(); - $nbofperiod=3; + $nbofperiod = 3; - if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION; + if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION; $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); $this->info_box_head = array( 'text' => $textHead, @@ -96,14 +96,14 @@ class box_activity extends ModeleBoxes ); // compute the year limit to show - $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); + $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m"); // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($this->db); + $propalstatic = new Propal($this->db); $cachedir = DOL_DATA_ROOT.'/propale/temp'; $filename = '/boxactivity-propal'.$fileid; @@ -112,29 +112,29 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; - $sql.= " AND p.date_cloture IS NULL"; // just unclosed - $sql.= " GROUP BY p.fk_statut"; - $sql.= " ORDER BY p.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; + $sql .= " AND p.date_cloture IS NULL"; // just unclosed + $sql .= " GROUP BY p.fk_statut"; + $sql .= " ORDER BY p.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -147,9 +147,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) + if (!empty($data)) { - $j=0; + $j = 0; while ($j < count($data)) { $this->info_box_contents[$line][0] = array( @@ -188,9 +188,9 @@ class box_activity extends ModeleBoxes } // list the summary of the orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $commandestatic=new Commande($this->db); + $commandestatic = new Commande($this->db); $langs->load("orders"); @@ -201,26 +201,26 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE c.entity = ".$conf->entity; - $sql.= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; - $sql.= " GROUP BY c.fk_statut"; - $sql.= " ORDER BY c.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; + $sql .= " GROUP BY c.fk_statut"; + $sql .= " ORDER BY c.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -231,8 +231,8 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $j=0; + if (!empty($data)) { + $j = 0; while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', @@ -271,10 +271,10 @@ class box_activity extends ModeleBoxes // list the summary of the bills - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($this->db); + $facturestatic = new Facture($this->db); // part 1 $cachedir = DOL_DATA_ROOT.'/facture/temp'; @@ -285,26 +285,26 @@ class box_activity extends ModeleBoxes if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -315,10 +315,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $j=0; + if (!empty($data)) { + $j = 0; while ($j < count($data)) { - $billurl="search_status=2&paye=1&year=".$data[$j]->annee; + $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), @@ -353,7 +353,7 @@ class box_activity extends ModeleBoxes $line++; $j++; } - if (count($data)==0) + if (count($data) == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), @@ -369,22 +369,22 @@ class box_activity extends ModeleBoxes $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').')'; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $j=0; + $j = 0; while ($j < $num) { - $data[$j]=$this->db->fetch_object($result); + $data[$j] = $this->db->fetch_object($result); $j++; } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } $this->db->free($result); @@ -395,12 +395,12 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - if (! empty($data)) { - $alreadypaid=-1; + if (!empty($data)) { + $alreadypaid = -1; - $j=0; + $j = 0; while ($j < count($data)) { - $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), @@ -431,7 +431,7 @@ class box_activity extends ModeleBoxes $line++; $j++; } - if (count($data)==0) { + if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 05d4e1d3ac0..7c8c110db88 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays extends ModeleBoxes { - public $boxcode="birthdays"; - public $boximg="object_user"; - public $boxlabel="BoxTitleUserBirthdaysOfMonth"; + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; public $depends = array("user"); /** @@ -60,7 +60,7 @@ class box_birthdays extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->user->user->lire && empty($user->socid)); + $this->hidden = !($user->rights->user->user->lire && empty($user->socid)); } /** @@ -74,24 +74,24 @@ class box_birthdays extends ModeleBoxes global $user, $langs; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic=new User($this->db); + $userstatic = new User($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { - $tmparray=dol_getdate(dol_now(), true); + $tmparray = dol_getdate(dol_now(), true); $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); - $sql.= " ORDER BY u.birth ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.entity IN (".getEntity('user').")"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); + $sql .= " ORDER BY u.birth ASC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -107,7 +107,7 @@ class box_birthdays extends ModeleBoxes $userstatic->firstname = $objp->firstname; $userstatic->lastname = $objp->lastname; $userstatic->email = $objp->email; - $dateb=$this->db->jdate($objp->birth); + $dateb = $this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -118,7 +118,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day") . ' - ' . $age . ' ' . $langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( @@ -129,7 +129,7 @@ class box_birthdays extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"','text'=>$langs->trans("None")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index e48271c4d84..96fc97f2e37 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays_members extends ModeleBoxes { - public $boxcode="birthdays_members"; - public $boximg="object_user"; - public $boxlabel="BoxTitleMemberNextBirthdays"; + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; public $depends = array("adherent"); /** @@ -60,7 +60,7 @@ class box_birthdays_members extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->adherent->lire && empty($user->socid)); + $this->hidden = !($user->rights->adherent->lire && empty($user->socid)); } /** @@ -74,25 +74,25 @@ class box_birthdays_members extends ModeleBoxes global $user, $langs; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { - $tmparray=dol_getdate(dol_now(), true); + $tmparray = dol_getdate(dol_now(), true); $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; - $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql.= " AND u.statut = 1"; - $sql.= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); - $sql.= " ORDER BY u.birth ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; + $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], $tmparray['year']); + $sql .= " ORDER BY u.birth ASC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -108,7 +108,7 @@ class box_birthdays_members extends ModeleBoxes $memberstatic->firstname = $objp->firstname; $memberstatic->lastname = $objp->lastname; $memberstatic->email = $objp->email; - $dateb=$this->db->jdate($objp->birth); + $dateb = $this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -119,7 +119,7 @@ class box_birthdays_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day") . ' - ' . $age . ' ' . $langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( @@ -130,7 +130,7 @@ class box_birthdays_members extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"','text'=>$langs->trans("None")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index 44102f0aab1..57c5ce2e2e2 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_boms extends ModeleBoxes { - public $boxcode="lastboms"; - public $boximg="object_bom"; - public $boxlabel="BoxTitleLatestModifiedBoms"; + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; public $depends = array("bom"); /** @@ -60,7 +60,7 @@ class box_boms extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->bom->read); + $this->hidden = !($user->rights->bom->read); } /** @@ -87,18 +87,18 @@ class box_boms extends ModeleBoxes if ($user->rights->bom->read) { $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql.= ", c.rowid"; - $sql.= ", c.date_creation"; - $sql.= ", c.tms"; - $sql.= ", c.ref"; - $sql.= ", c.status"; - $sql.= ", c.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql.= " WHERE c.fk_product = p.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.tms DESC, c.ref DESC"; - $sql.= " ".$this->db->plimit($max, 0); + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -108,7 +108,7 @@ class box_boms extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $bomstatic->id = $objp->rowid; $bomstatic->ref = $objp->ref; @@ -131,11 +131,11 @@ class box_boms extends ModeleBoxes 'asis' => 1, ); - if (! empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -153,7 +153,7 @@ class box_boms extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 10b9c52acb0..37a25c8084d 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - public $boxcode="lastcustomerorders"; - public $boximg="object_order"; - public $boxlabel="BoxLastCustomerOrders"; + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; public $depends = array("commande"); /** @@ -60,7 +60,7 @@ class box_commandes extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->commande->lire); + $this->hidden = !($user->rights->commande->lire); } /** @@ -83,35 +83,35 @@ class box_commandes extends ModeleBoxes $societestatic = new Societe($this->db); $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); if ($user->rights->commande->lire) { $sql = "SELECT s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.logo, s.email"; - $sql.= ", c.ref, c.tms"; - $sql.= ", c.rowid"; - $sql.= ", c.date_commande"; - $sql.= ", c.ref_client"; - $sql.= ", c.fk_statut"; - $sql.= ", c.fk_user_valid"; - $sql.= ", c.facture"; - $sql.= ", c.total_ht"; - $sql.= ", c.tva as total_tva"; - $sql.= ", c.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -121,8 +121,8 @@ class box_commandes extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); $commandestatic->id = $objp->rowid; $commandestatic->ref = $objp->ref; $commandestatic->ref_client = $objp->ref_client; @@ -152,11 +152,11 @@ class box_commandes extends ModeleBoxes 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -174,7 +174,7 @@ class box_commandes extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 00f5722076c..b3f23817712 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,10 +33,10 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - public $boxcode="currentaccounts"; - public $boximg="object_bill"; - public $boxlabel="BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active /** * @var DoliDB Database handler. @@ -63,10 +63,10 @@ class box_comptes extends ModeleBoxes $this->db = $db; // disable module for such cases - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('banque', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('banque', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users - $this->hidden = ! ($user->rights->banque->lire); + $this->hidden = !($user->rights->banque->lire); } /** @@ -79,25 +79,25 @@ class box_comptes extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; - $sql.= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; - $sql.= ", b.domiciliation, b.proprio, b.owner_address"; - $sql.= ", b.account_number, b.currency_code"; - $sql.= ", b.min_allowed, b.min_desired, comment"; - $sql.= ', b.fk_accountancy_journal'; - $sql.= ', aj.code as accountancy_journal'; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql.= " WHERE b.entity = ".$conf->entity; - $sql.= " AND clos = 0"; + $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; + $sql .= ", b.domiciliation, b.proprio, b.owner_address"; + $sql .= ", b.account_number, b.currency_code"; + $sql .= ", b.min_allowed, b.min_desired, comment"; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; - $sql.= " ORDER BY label"; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY label"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -118,7 +118,7 @@ class box_comptes extends ModeleBoxes $account_static->account_number = $objp->account_number; $account_static->currency_code = $objp->currency_code; $account_static->accountancy_journal = $objp->accountancy_journal; - $solde=$account_static->solde(0); + $solde = $account_static->solde(0); $solde_total[$objp->currency_code] += $solde; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 36a4f5416f9..75fbc207134 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - public $boxcode="lastcontracts"; - public $boximg="object_contract"; - public $boxlabel="BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->contrat->lire); + $this->hidden = !($user->rights->contrat->lire); } /** @@ -72,7 +72,7 @@ class box_contracts extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; @@ -80,27 +80,27 @@ class box_contracts extends ModeleBoxes if ($user->rights->contrat->lire) { - $contractstatic=new Contrat($this->db); - $thirdpartytmp=new Societe($this->db); + $contractstatic = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql.= ", c.ref_customer, c.ref_supplier"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $now=dol_now(); + $now = dol_now(); $line = 0; @@ -110,17 +110,17 @@ class box_contracts extends ModeleBoxes { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $dateterm=$this->db->jdate($objp->fin_validite); - $dateclose=$this->db->jdate($objp->date_cloture); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; - $contractstatic->statut=$objp->fk_statut; - $contractstatic->id=$objp->rowid; - $contractstatic->ref=$objp->ref; + $contractstatic->statut = $objp->fk_statut; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; $contractstatic->ref_customer = $objp->ref_customer; $contractstatic->ref_supplier = $objp->ref_supplier; - $result=$contractstatic->fetch_lines(); + $result = $contractstatic->fetch_lines(); $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -162,7 +162,7 @@ class box_contracts extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center opacitymedium"', 'text'=>$langs->trans("NoRecordedContracts"), diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index e0ac847c6f0..93ac43d6c22 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - public $boxcode="lastrssinfos"; - public $boximg="object_rss"; - public $boxlabel="BoxLastRssInfos"; + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; public $depends = array("externalrss"); /** @@ -44,7 +44,7 @@ class box_external_rss extends ModeleBoxes */ public $db; - public $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) public $info_box_head = array(); public $info_box_contents = array(); @@ -58,8 +58,8 @@ class box_external_rss extends ModeleBoxes */ public function __construct($db, $param) { - $this->db=$db; - $this->paramdef=$param; + $this->db = $db; + $this->paramdef = $param; } /** @@ -74,93 +74,93 @@ class box_external_rss extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; // On recupere numero de param de la boite preg_match('/^([0-9]+) /', $this->paramdef, $reg); - $site=$reg[1]; + $site = $reg[1]; // Create dir nor required // documents/externalrss is created by module activation // documents/externalrss/tmp is created by rssparser - $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; - $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; + $keyforparamurl = "EXTERNAL_RSS_URLRSS_".$site; + $keyforparamtitle = "EXTERNAL_RSS_TITLE_".$site; // Get RSS feed - $url=$conf->global->$keyforparamurl; + $url = $conf->global->$keyforparamurl; - $rssparser=new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel - $description=$rssparser->getDescription(); - $link=$rssparser->getLink(); + $description = $rssparser->getDescription(); + $link = $rssparser->getLink(); - $title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || ! empty($rssparser->error)) + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) { // Show warning - $title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext"):$langs->trans("Unknown")))); - $this->info_box_head = array('text' => $title,'limit' => 0); + $title .= " ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")))); + $this->info_box_head = array('text' => $title, 'limit' => 0); } else { $this->info_box_head = array( 'text' => $title, 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext"):$langs->trans("Unknown")), + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), 'subpicto'=>'globe', 'target'=>'_blank', ); } // INFO on items - $items=$rssparser->getItems(); + $items = $rssparser->getItems(); //print '
'.print_r($items,true).'
'; - $nbitems=count($items); - for($line = 0; $line < $max && $line < $nbitems; $line++) + $nbitems = count($items); + for ($line = 0; $line < $max && $line < $nbitems; $line++) { $item = $items[$line]; // Feed common fields - $href = $item['link']; + $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { - if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; - if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; + if (!$date && isset($item['pubdate'])) $date = $item['pubdate']; + if (!$date && isset($item['dc']['date'])) $date = $item['dc']['date']; //$item['dc']['language'] //$item['dc']['publisher'] } if ($rssparser->getFormat() == 'atom') // If Atom { - if (! $date && isset($item['issued'])) $date=$item['issued']; - if (! $date && isset($item['modified'])) $date=$item['modified']; + if (!$date && isset($item['issued'])) $date = $item['issued']; + if (!$date && isset($item['modified'])) $date = $item['modified']; //$item['issued'] //$item['modified'] //$item['atom_content'] } - if (is_numeric($date)) $date=dol_print_date($date, "dayhour"); + if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title=preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"]="$title"; + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; $tooltip = $title; - $description = ! empty($item['description'])?$item['description']:''; + $description = !empty($item['description']) ? $item['description'] : ''; $isutf8 = utf8_check($description); - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $description=utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description=utf8_decode($description); - $description=preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description=preg_replace("/^\s+/", "", $description); - $description=str_replace("\r\n", "", $description); - $tooltip.= '
'.$description; + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
'.$description; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 65724f5fa4b..ebaff31268d 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - public $boxcode="lastcustomerbills"; - public $boximg="object_bill"; - public $boxlabel="BoxLastCustomerBills"; + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; public $depends = array("facture"); /** @@ -58,7 +58,7 @@ class box_factures extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** @@ -71,7 +71,7 @@ class box_factures extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -81,7 +81,7 @@ class box_factures extends ModeleBoxes $langs->load("bills"); - $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills", $max); + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text) @@ -89,29 +89,29 @@ class box_factures extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT f.rowid as facid"; - $sql.= ", f.ref, f.type, f.total as total_ht"; - $sql.= ", f.tva as total_tva"; - $sql.= ", f.total_ttc"; - $sql.= ", f.datef as df"; - $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; + $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now=dol_now(); + $now = dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; @@ -179,7 +179,7 @@ class box_factures extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9eb836fe1e2..30f3cd503c2 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - public $boxcode="lastsupplierbills"; - public $boximg="object_bill"; - public $boxlabel="BoxLastSupplierBills"; - public $depends = array("facture","fournisseur"); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_factures_fourn extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -72,7 +72,7 @@ class box_factures_fourn extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; @@ -81,32 +81,32 @@ class box_factures_fourn extends ModeleBoxes $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( - 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills", $max) + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) ); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_fournisseur, s.email,"; - $sql.= " s.logo,"; - $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; - $sql.= " f.total_ht,"; - $sql.= " f.total_tva,"; - $sql.= " f.total_ttc,"; - $sql.= " f.paye, f.fk_statut,"; - $sql.= ' f.datef as df,'; - $sql.= ' f.datec as datec,'; - $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut,"; + $sql .= ' f.datef as df,'; + $sql .= ' f.datec as datec,'; + $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -114,13 +114,13 @@ class box_factures_fourn extends ModeleBoxes $num = $this->db->num_rows($result); $line = 0; - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite=$this->db->jdate($objp->datelimite); - $date=$this->db->jdate($objp->df); - $datem=$this->db->jdate($objp->tms); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; @@ -141,7 +141,7 @@ class box_factures_fourn extends ModeleBoxes $late = ''; if ($facturestatic->hasDelay()) { - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } $this->info_box_contents[$line][] = array( @@ -154,7 +154,7 @@ class box_factures_fourn extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150"', 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, ); @@ -176,7 +176,7 @@ class box_factures_fourn extends ModeleBoxes $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); - $alreadypaid=$fac->getSommePaiement(); + $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), @@ -185,7 +185,7 @@ class box_factures_fourn extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoModifiedSupplierBills"), diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index b1b108931b1..c2b5e7c705e 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -33,7 +33,7 @@ class box_factures_fourn_imp extends ModeleBoxes public $boxcode = "oldestunpaidsupplierbills"; public $boximg = "object_bill"; public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture","fournisseur"); + public $depends = array("facture", "fournisseur"); /** * @var DoliDB Database handler. @@ -58,7 +58,7 @@ class box_factures_fourn_imp extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -71,35 +71,35 @@ class box_factures_fourn_imp extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $facturestatic=new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; - $sql.= " f.datef as df,"; - $sql.= " f.total_ht as total_ht,"; - $sql.= " f.tva as total_tva,"; - $sql.= " f.total_ttc,"; - $sql.= " f.paye, f.fk_statut, f.type"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ",".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.paye=0"; - $sql.= " AND fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY datelimite DESC, f.ref_supplier DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; + $sql .= " f.datef as df,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut, f.type"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.paye=0"; + $sql .= " AND fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY datelimite DESC, f.ref_supplier DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -114,9 +114,9 @@ class box_factures_fourn_imp extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite=$this->db->jdate($objp->datelimite); - $date=$this->db->jdate($objp->df); - $datem=$this->db->jdate($objp->tms); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; @@ -130,12 +130,12 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; - $late=''; + $late = ''; if ($facturestatic->hasDelay()) { - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref?$objp->ref:$objp->facid) . '
' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier; + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', @@ -162,7 +162,7 @@ class box_factures_fourn_imp extends ModeleBoxes $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); - $alreadypaid=$fac->getSommePaiement(); + $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), @@ -171,7 +171,7 @@ class box_factures_fourn_imp extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoUnpaidSupplierBills"), diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index a81b0cf3b86..e289c83d541 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,10 +31,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - public $boxcode="ficheinter"; - public $boximg="object_intervention"; - public $boxlabel="BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** * @var DoliDB Database handler. @@ -59,7 +59,7 @@ class box_ficheinter extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -72,37 +72,37 @@ class box_ficheinter extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $ficheinterstatic=new Fichinter($this->db); + $ficheinterstatic = new Fichinter($this->db); $companystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); - if (! empty($user->rights->ficheinter->lire)) + if (!empty($user->rights->ficheinter->lire)) { $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,"; - $sql.= " f.datec,"; - $sql.= " f.date_valid as datev,"; - $sql.= " f.tms as datem,"; - $sql.= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; - $sql.= " WHERE f.fk_soc = s.rowid "; - $sql.= " AND f.entity = ".$conf->entity; - if (! $user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY f.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " f.datec,"; + $sql .= " f.date_valid as datev,"; + $sql .= " f.tms as datem,"; + $sql .= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; + $sql .= " WHERE f.fk_soc = s.rowid "; + $sql .= " AND f.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY f.tms DESC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $now=dol_now(); + $now = dol_now(); $i = 0; @@ -111,9 +111,9 @@ class box_ficheinter extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); - $ficheinterstatic->statut=$objp->fk_statut; - $ficheinterstatic->id=$objp->rowid; - $ficheinterstatic->ref=$objp->ref; + $ficheinterstatic->statut = $objp->fk_statut; + $ficheinterstatic->id = $objp->rowid; + $ficheinterstatic->ref = $objp->ref; $companystatic->id = $objp->socid; $companystatic->name = $objp->name; @@ -145,7 +145,7 @@ class box_ficheinter extends ModeleBoxes $i++; } - if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions")); + if ($num == 0) $this->info_box_contents[$i][] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInterventions")); $this->db->free($resql); } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 242f26e5d60..2b2d8418e47 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - public $boxcode="lastmembers"; - public $boximg="object_user"; - public $boxlabel="BoxLastMembers"; + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; public $depends = array("adherent"); /** @@ -62,10 +62,10 @@ class box_members extends ModeleBoxes $this->db = $db; // disable module for such cases - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (! in_array('adherent', $listofmodulesforexternal) && ! empty($user->socid)) $this->enabled=0; // disabled for external users + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users - $this->hidden = ! ($user->rights->adherent->lire); + $this->hidden = !($user->rights->adherent->lire); } /** @@ -79,23 +79,23 @@ class box_members extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); if ($user->rights->adherent->lire) { $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; - $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; - $sql.= " t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity IN (".getEntity('member').")"; - $sql.= " AND a.fk_adherent_type = t.rowid"; - $sql.= " ORDER BY a.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= " t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = t.rowid"; + $sql .= " ORDER BY a.tms DESC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -106,21 +106,21 @@ class box_members extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); - $memberstatic->lastname=$objp->lastname; - $memberstatic->firstname=$objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; $memberstatic->ref = $objp->rowid; $memberstatic->company = $objp->company; - if (! empty($objp->fk_soc)) { + if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; $memberstatic->fetch_thirdparty(); - $memberstatic->name=$memberstatic->thirdparty->name; + $memberstatic->name = $memberstatic->thirdparty->name; } else { - $memberstatic->name=$objp->company; + $memberstatic->name = $objp->company; } $this->info_box_contents[$line][] = array( @@ -148,7 +148,7 @@ class box_members extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"), diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 949f63776f6..9b863aa2d5a 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_mos extends ModeleBoxes { - public $boxcode="lastmos"; - public $boximg="object_mrp"; - public $boxlabel="BoxTitleLatestModifiedMos"; + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; public $depends = array("mrp"); /** @@ -60,7 +60,7 @@ class box_mos extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->bom->read); + $this->hidden = !($user->rights->bom->read); } /** @@ -87,18 +87,18 @@ class box_mos extends ModeleBoxes if ($user->rights->mrp->read) { $sql = "SELECT p.ref as product_ref"; - $sql.= ", c.rowid"; - $sql.= ", c.date_creation"; - $sql.= ", c.tms"; - $sql.= ", c.ref"; - $sql.= ", c.status"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; //$sql.= ", c.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql.= " WHERE c.fk_product = p.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.tms DESC, c.ref DESC"; - $sql.= " ".$this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -108,7 +108,7 @@ class box_mos extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $mostatic->id = $objp->rowid; $mostatic->ref = $objp->ref; $mostatic->id = $objp->socid; @@ -127,11 +127,11 @@ class box_mos extends ModeleBoxes 'asis' => 1, ); - if (! empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), 'asis' => 1, ); } @@ -149,7 +149,7 @@ class box_mos extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedOrders")); $this->db->free($result); } else { diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 5cccd24ad6a..374e9ab1bae 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - public $boxcode="lastproducts"; - public $boximg="object_product"; - public $boxlabel="BoxLastProducts"; + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; public $depends = array("produit"); /** @@ -59,11 +59,11 @@ class box_produits extends ModeleBoxes { global $conf, $user; - $this->db=$db; + $this->db = $db; - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } @@ -77,29 +77,29 @@ class box_produits extends ModeleBoxes { global $user, $langs, $conf, $hookmanager; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($this->db); + $productstatic = new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks if (is_object($hookmanager)) { - $parameters=array('boxproductlist'=>1); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } - $sql.= $this->db->order('p.datec', 'DESC'); - $sql.= $this->db->plimit($max, 0); + $sql .= $this->db->order('p.datec', 'DESC'); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -109,16 +109,16 @@ class box_produits extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->rowid; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->rowid; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -147,8 +147,8 @@ class box_produits extends ModeleBoxes $price = ''; $price_base_type = ''; if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type=$langs->trans($objp->price_base_type); - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); } else //Parse the dynamic price { @@ -158,14 +158,14 @@ class box_produits extends ModeleBoxes if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { - $price_base_type=$langs->trans("HT"); + $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); - $price_base_type=$langs->trans("TTC"); + $price_base_type = $langs->trans("TTC"); } - $price=price($price_result); + $price = price($price_result); } } $this->info_box_contents[$line][] = array( @@ -197,7 +197,7 @@ class box_produits extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProducts"), diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 3c674cd32c0..f4a433c013d 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,9 +35,9 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode="productsalertstock"; - public $boximg="object_product"; - public $boxlabel="BoxProductsAlertStock"; + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; public $depends = array("produit"); /** @@ -59,13 +59,13 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf,$user; + global $conf, $user; $this->db = $db; - $listofmodulesforexternal=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry=array('enabled'=>((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ! empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode=isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } @@ -79,34 +79,34 @@ class box_produits_alerte_stock extends ModeleBoxes { global $user, $langs, $conf, $hookmanager; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($this->db); + $productstatic = new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; - $sql.= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; - if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; - if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql .= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; + $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; + $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks if (is_object($hookmanager)) { - $parameters=array('boxproductalertstocklist'=>1); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; - $sql.= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; - $sql.= $this->db->order('p.seuil_stock_alerte', 'DESC'); - $sql.= $this->db->plimit($max, 0); + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; + $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + $sql .= $this->db->order('p.seuil_stock_alerte', 'DESC'); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -116,18 +116,18 @@ class box_produits_alerte_stock extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $price = ''; $price_base_type = ''; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->rowid; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->rowid; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -156,8 +156,8 @@ class box_produits_alerte_stock extends ModeleBoxes if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type=$langs->trans($objp->price_base_type); - $price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc); + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); } else //Parse the dynamic price { @@ -167,14 +167,14 @@ class box_produits_alerte_stock extends ModeleBoxes if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { - $price_base_type=$langs->trans("HT"); + $price_base_type = $langs->trans("HT"); } else { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); - $price_base_type=$langs->trans("TTC"); + $price_base_type = $langs->trans("TTC"); } - $price=price($price_result); + $price = price($price_result); } } @@ -190,7 +190,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => $objp->total_stock . ' / '.$objp->seuil_stock_alerte, + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); @@ -208,7 +208,7 @@ class box_produits_alerte_stock extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoTooLowStockProducts"), diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 9fffc92963f..c99f07ff311 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -31,8 +31,8 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - public $boxcode="project"; - public $boximg="object_projectpub"; + public $boxcode = "project"; + public $boximg = "object_projectpub"; public $boxlabel; //var $depends = array("projet"); @@ -62,7 +62,7 @@ class box_project extends ModeleBoxes $this->db = $db; $this->boxlabel = "OpenedProjects"; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); } /** @@ -75,11 +75,11 @@ class box_project extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; $totalMnt = 0; $totalnb = 0; - $totalnbTask=0; + $totalnbTask = 0; $textHead = $langs->trans("OpenedProjects"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); @@ -89,20 +89,20 @@ class box_project extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); - $socid=0; + $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok - $sql.= " AND p.fk_statut = 1"; // Only open projects - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql .= " AND p.fk_statut = 1"; // Only open projects + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - $sql.= " ORDER BY p.datec DESC"; + $sql .= " ORDER BY p.datec DESC"; //$sql.= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -130,10 +130,10 @@ class box_project extends ModeleBoxes 'text' => $objp->title, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('project').')'; + $sql .= " AND p.rowid = ".$objp->rowid; $resultTask = $this->db->query($sql); if ($resultTask) { $objTask = $this->db->fetch_object($resultTask); @@ -141,10 +141,10 @@ class box_project extends ModeleBoxes 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), ); - if ($objTask->nb > 0) + if ($objTask->nb > 0) $this->info_box_contents[$i][] = array( 'td' => 'class="right"', - 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", ); else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 9d6a10b6225..54ed1c76051 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - public $boxcode="lastprospects"; - public $boximg="object_company"; - public $boxlabel="BoxLastProspects"; + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; public $depends = array("societe"); /** @@ -63,9 +63,9 @@ class box_prospect extends ModeleBoxes $this->db = $db; // disable box for such cases - if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled = 0; // disabled by this option - $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); } /** @@ -78,29 +78,29 @@ class box_prospect extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; - $thirdpartystatic=new Client($this->db); + $thirdpartystatic = new Client($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.client, s.email"; - $sql.= ", s.code_fournisseur"; - $sql.= ", s.fournisseur"; - $sql.= ", s.logo"; - $sql.= ", s.fk_stcomm, s.datec, s.tms, s.status"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.client IN (2, 3)"; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " ORDER BY s.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.code_client"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (2, 3)"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC"; + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $resql = $this->db->query($sql); @@ -112,8 +112,8 @@ class box_prospect extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->email = $objp->email; @@ -147,7 +147,7 @@ class box_prospect extends ModeleBoxes $line++; } - if ($num==0) { + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedProspects"), diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 5b40fc61436..f8e6dd22452 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,10 +32,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - public $boxcode="lastproductsincontract"; - public $boximg="object_product"; - public $boxlabel="BoxLastProductsInContract"; - public $depends = array("service","contrat"); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); /** * @var DoliDB Database handler. @@ -60,7 +60,7 @@ class box_services_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** @@ -73,7 +73,7 @@ class box_services_contracts extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; @@ -83,52 +83,52 @@ class box_services_contracts extends ModeleBoxes if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic=new Contrat($this->db); - $contractlinestatic=new ContratLigne($this->db); + $contractstatic = new Contrat($this->db); + $contractlinestatic = new ContratLigne($this->db); $thirdpartytmp = new Societe($this->db); $productstatic = new Product($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; - $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= ")"; - $sql.= " WHERE c.entity = ".$conf->entity; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= $this->db->order("c.tms", "DESC"); - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; + $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= ")"; + $sql .= " WHERE c.entity = ".$conf->entity; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= $this->db->order("c.tms", "DESC"); + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now=dol_now(); + $now = dol_now(); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->datem); + $datem = $this->db->jdate($objp->datem); - $contractlinestatic->id=$objp->cdid; - $contractlinestatic->fk_contrat=$objp->rowid; - $contractlinestatic->label=$objp->label; - $contractlinestatic->description=$objp->description; - $contractlinestatic->type=$objp->type; - $contractlinestatic->product_id=$objp->product_id; - $contractlinestatic->product_ref=$objp->product_ref; + $contractlinestatic->id = $objp->cdid; + $contractlinestatic->fk_contrat = $objp->rowid; + $contractlinestatic->label = $objp->label; + $contractlinestatic->description = $objp->description; + $contractlinestatic->type = $objp->type; + $contractlinestatic->product_id = $objp->product_id; + $contractlinestatic->product_ref = $objp->product_ref; - $contractstatic->statut=$objp->contract_status; - $contractstatic->id=$objp->rowid; - $contractstatic->ref=$objp->ref; - $contractstatic->ref_customer=$objp->ref_customer; - $contractstatic->ref_supplier=$objp->ref_supplier; + $contractstatic->statut = $objp->contract_status; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -141,13 +141,13 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on + if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on { $sqld = "SELECT label"; - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld.= " WHERE fk_product=".$objp->product_id; - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; - $sqld.= " LIMIT 1"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->product_id; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); if ($resultd) @@ -160,11 +160,11 @@ class box_services_contracts extends ModeleBoxes // Label if ($objp->product_id > 0) { - $productstatic->id=$objp->product_id; - $productstatic->type=$objp->ptype; - $productstatic->ref=$objp->product_ref; - $productstatic->entity=$objp->pentity; - $productstatic->label=$objp->plabel; + $productstatic->id = $objp->product_id; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->product_ref; + $productstatic->entity = $objp->pentity; + $productstatic->label = $objp->plabel; $productstatic->status = $objp->tosell; $productstatic->status_buy = $objp->tobuy; @@ -179,13 +179,13 @@ class box_services_contracts extends ModeleBoxes $description = $objp->description; // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; - $description = ''; // Already added into main visible desc + $description = ''; // Already added into main visible desc } - $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { @@ -223,7 +223,7 @@ class box_services_contracts extends ModeleBoxes $i++; } - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("NoContractedProducts")); + if ($num == 0) $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoContractedProducts")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 881e17f73ec..c019062313c 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -33,7 +33,7 @@ class box_supplier_orders extends ModeleBoxes public $boxcode = "latestsupplierorders"; public $boximg = "object_order"; - public $boxlabel="BoxLatestSupplierOrders"; + public $boxlabel = "BoxLatestSupplierOrders"; public $depends = array("fournisseur"); /** @@ -58,7 +58,7 @@ class box_supplier_orders extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -75,32 +75,32 @@ class box_supplier_orders extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($this->db); + $supplierorderstatic = new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_client, s.code_fournisseur,"; - $sql.= " s.logo, s.email,"; - $sql.= " c.rowid, c.ref, c.tms, c.date_commande,"; - $sql.= " c.total_ht,"; - $sql.= " c.tva as total_tva,"; - $sql.= " c.total_ttc,"; - $sql.= " c.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -110,8 +110,8 @@ class box_supplier_orders extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 416dc7f2f2a..f70f5bef450 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -33,7 +33,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes public $boxcode = "supplierordersawaitingreception"; public $boximg = "object_order"; - public $boxlabel="BoxLatestSupplierOrdersAwaitingReception"; + public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; public $depends = array("fournisseur"); /** @@ -58,7 +58,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -75,7 +75,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($this->db); + $supplierorderstatic = new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); @@ -84,25 +84,25 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_client, s.code_fournisseur, s.email,"; - $sql.= " s.logo,"; - $sql.= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; - $sql.= " c.total_ht,"; - $sql.= " c.tva as total_tva,"; - $sql.= " c.total_ttc,"; - $sql.= " c.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql .= " s.code_client, s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->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.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql.= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) @@ -112,9 +112,9 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $date=$this->db->jdate($objp->date_commande); - $date_livraison=$this->db->jdate($objp->date_livraison); - $datem=$this->db->jdate($objp->tms); + $date = $this->db->jdate($objp->date_commande); + $date_livraison = $this->db->jdate($objp->date_livraison); + $datem = $this->db->jdate($objp->tms); $supplierorderstatic->date_livraison = $date_livraison; $supplierorderstatic->statut = $objp->fk_statut; @@ -153,7 +153,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $delayIcon.' '. dol_print_date($date_livraison, 'day').'', + 'text' => $delayIcon.' '.dol_print_date($date_livraison, 'day').'', 'asis' => 1 ); diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index f8888c71a4b..f9a974ae1c5 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -127,7 +127,7 @@ class box_task extends ModeleBoxes $boxcontent .= ''; $boxcontent .= ''."\n"; $boxcontent .= '
'."\n"; - if (! empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $boxcontent .= '' ; - exit ; + $rpl = array('\\' => '\\\\', '"' => '\\"'); + echo 'window.parent.OnUploadCompleted('.$errorNumber.',"'.strtr($fileUrl, $rpl).'","'.strtr($fileName, $rpl).'", "'.strtr($customMsg, $rpl).'");'; + echo ''; + exit; } @@ -403,9 +403,9 @@ function SendCKEditorResults($callback, $sFileUrl, $customMsg = '') { echo ''; } diff --git a/htdocs/core/filemanagerdol/connectors/php/upload.php b/htdocs/core/filemanagerdol/connectors/php/upload.php index 9364f3bd540..b1f97d10395 100644 --- a/htdocs/core/filemanagerdol/connectors/php/upload.php +++ b/htdocs/core/filemanagerdol/connectors/php/upload.php @@ -41,22 +41,22 @@ function SendError($number, $text) // Check if this uploader has been enabled. -if ( !$Config['Enabled'] ) +if (!$Config['Enabled']) SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "filemanagerdol/connectors/php/config.php" file'); -$sCommand = 'QuickUpload' ; +$sCommand = 'QuickUpload'; // The file type (from the QueryString, by default 'File'). -$sType = isset($_GET['Type']) ? $_GET['Type'] : 'File' ; +$sType = isset($_GET['Type']) ? $_GET['Type'] : 'File'; -$sCurrentFolder = "/" ; +$sCurrentFolder = "/"; // Is enabled the upload? -if (! IsAllowedCommand($sCommand)) - SendUploadResults('1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed'); +if (!IsAllowedCommand($sCommand)) + SendUploadResults('1', '', '', 'The ""'.$sCommand.'"" command isn\'t allowed'); // Check if it is an allowed type. -if (! IsAllowedType($sType)) +if (!IsAllowedType($sType)) SendUploadResults(1, '', '', 'Invalid type specified'); diff --git a/htdocs/core/filemanagerdol/connectors/php/util.php b/htdocs/core/filemanagerdol/connectors/php/util.php index 9f80b96b2fd..3ea4baf8c87 100644 --- a/htdocs/core/filemanagerdol/connectors/php/util.php +++ b/htdocs/core/filemanagerdol/connectors/php/util.php @@ -31,7 +31,7 @@ */ function RemoveFromStart($sourceString, $charToRemove) { - $sPattern = '|^' . $charToRemove . '+|' ; + $sPattern = '|^'.$charToRemove.'+|'; return preg_replace($sPattern, '', $sourceString); } @@ -44,7 +44,7 @@ function RemoveFromStart($sourceString, $charToRemove) */ function RemoveFromEnd($sourceString, $charToRemove) { - $sPattern = '|' . $charToRemove . '+$|' ; + $sPattern = '|'.$charToRemove.'+$|'; return preg_replace($sPattern, '', $sourceString); } @@ -67,7 +67,7 @@ function FindBadUtf8($string) '|(.{1}))'; while (preg_match('/'.$regex.'/S', $string, $matches)) { - if ( isset($matches[2])) { + if (isset($matches[2])) { return true; } $string = substr($string, strlen($matches[0])); @@ -84,9 +84,9 @@ function FindBadUtf8($string) */ function ConvertToXmlAttribute($value) { - if ( defined('PHP_OS') ) + if (defined('PHP_OS')) { - $os = PHP_OS ; + $os = PHP_OS; } else { @@ -112,9 +112,9 @@ function ConvertToXmlAttribute($value) */ function IsHtmlExtension($ext, $formExtensions) { - if (!$formExtensions || !is_array($formExtensions) ) + if (!$formExtensions || !is_array($formExtensions)) { - return false ; + return false; } $lcaseHtmlExtensions = array(); foreach ($formExtensions as $key => $val) @@ -137,9 +137,9 @@ function DetectHtml($filePath) $fp = @fopen($filePath, 'rb'); //open_basedir restriction, see #1906 - if ( $fp === false || !flock($fp, LOCK_SH) ) + if ($fp === false || !flock($fp, LOCK_SH)) { - return -1 ; + return -1; } $chunk = fread($fp, 1024); @@ -150,47 +150,47 @@ function DetectHtml($filePath) if (!$chunk) { - return false ; + return false; } $chunk = trim($chunk); - if ( preg_match("/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("Menu"); +$title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?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); print ''."\n"; @@ -176,34 +176,34 @@ $(document).ready(function(){ if (empty($user->socid)) // If internal user or not defined { - $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED); + $conf->standard_menu = (empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENU_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED); } else // If external user { - $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); + $conf->standard_menu = (empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENUFRONT_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED); } // Load the menu manager (only if not already done) -$file_menu=$conf->standard_menu; -if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php -if (! class_exists('MenuManager')) +$file_menu = $conf->standard_menu; +if (GETPOST('menu')) $file_menu = GETPOST('menu'); // example: menu=eldy_menu.php +if (!class_exists('MenuManager')) { - $menufound=0; - $dirmenus=array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); - foreach($dirmenus as $dirmenu) + $menufound = 0; + $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); + foreach ($dirmenus as $dirmenu) { - $menufound=dol_include_once($dirmenu."standard/".$file_menu); + $menufound = dol_include_once($dirmenu."standard/".$file_menu); if ($menufound) break; } - if (! $menufound) // If failed to include, we try with standard + if (!$menufound) // If failed to include, we try with standard { dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); - $file_menu='eldy_menu.php'; + $file_menu = 'eldy_menu.php'; include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } -$menumanager = new MenuManager($db, empty($user->socid)?0:1); -$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries +$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); +$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries //var_dump($menumanager);exit; $menumanager->showmenu('jmobile'); diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index c40dd571190..40596596b97 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -62,7 +62,7 @@ if (empty($conf->dol_no_mouse_hover)) print ' jQuery(".classfortooltiponclicktext").dialog( { closeOnEscape: true, classes: { "ui-dialog": "highlight" }, - maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth']-20, 320) : 700).', + maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth'] - 20, 320) : 700).', modal: true, autoOpen: false }).css("z-index: 5000"); jQuery(".classfortooltiponclick").click(function () { @@ -79,7 +79,7 @@ print "});\n"; // Wrapper to manage dropdown -if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) +if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { print "\n/* JS CODE TO ENABLE dropdown (hamburger, linkto, ...) */\n"; print ' @@ -151,7 +151,7 @@ if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) // Wrapper to manage document_preview if ($conf->browser->layout != 'phone') { - print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header + print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header print ' jQuery(document).ready(function () { jQuery(".documentpreview").click(function () { diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php index 9e1a85b57c4..59a1e5fddb5 100644 --- a/htdocs/core/js/lib_gravatar.js.php +++ b/htdocs/core/js/lib_gravatar.js.php @@ -24,14 +24,14 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +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('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index a35fee85d0a..1efa4c88771 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -24,13 +24,13 @@ * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -45,7 +45,7 @@ else header('Cache-Control: no-cache'); // Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8) -$tradMonths=array( +$tradMonths = array( dol_escape_js($langs->transnoentitiesnoconv("Month01")), dol_escape_js($langs->transnoentitiesnoconv("Month02")), dol_escape_js($langs->transnoentitiesnoconv("Month03")), @@ -60,7 +60,7 @@ dol_escape_js($langs->transnoentitiesnoconv("Month11")), dol_escape_js($langs->transnoentitiesnoconv("Month12")) ); -$tradMonthsShort=array( +$tradMonthsShort = array( $langs->trans("MonthShort01"), $langs->trans("MonthShort02"), $langs->trans("MonthShort03"), @@ -75,7 +75,7 @@ $langs->trans("MonthShort11"), $langs->trans("MonthShort12") ); -$tradDays=array( +$tradDays = array( $langs->trans("Sunday"), $langs->trans("Monday"), $langs->trans("Tuesday"), @@ -85,7 +85,7 @@ $langs->trans("Friday"), $langs->trans("Saturday") ); -$tradDaysShort=array( +$tradDaysShort = array( $langs->trans("ShortSunday"), $langs->trans("ShortMonday"), $langs->trans("ShortTuesday"), @@ -95,7 +95,7 @@ $langs->trans("ShortFriday"), $langs->trans("ShortSaturday") ); -$tradDaysMin=array( +$tradDaysMin = array( $langs->trans("SundayMin"), $langs->trans("MondayMin"), $langs->trans("TuesdayMin"), @@ -139,8 +139,8 @@ jQuery(function($){ dayNamesMin: tradDaysMin, weekHeader: 'trans("Week"); ?>', dateFormat: 'trans("FormatDateShortJQuery"); ?>', /* Note dd/mm/yy means year on 4 digit in jquery format */ - firstDay: global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, - isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?>, + firstDay: global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'); ?>, + isRTL: trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?>, showMonthAfterYear: false, /* TODO add specific to country */ yearSuffix: '' /* TODO add specific to country */ }; @@ -1060,8 +1060,8 @@ function price2numjs(amount) { if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); } - if ($thousand == 'Space') $thousand=' '; - print "var dec='" . dol_escape_js($dec) . "'; var thousand='" . dol_escape_js($thousand) . "';\n"; // Set var in javascript + if ($thousand == 'Space') $thousand = ' '; + print "var dec='".dol_escape_js($dec)."'; var thousand='".dol_escape_js($thousand)."';\n"; // Set var in javascript ?> var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>; @@ -1093,7 +1093,7 @@ function price2numjs(amount) { global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { +if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { ?> // Defined properties for JNotify $(document).ready(function() { diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index e78161d167d..3e4f838fe33 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -29,15 +29,15 @@ if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); require_once '../../main.inc.php'; -if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/index.php' +if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/index.php' || preg_match('/getmenu_div\.php/', $_SERVER['HTTP_REFERER']))) { global $langs, $conf; top_httphead('text/javascript; charset=UTF-8'); - print 'var login = \'' . $_SESSION['dol_login'] . '\';' . "\n"; - print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined + print 'var login = \''.$_SESSION['dol_login'].'\';'."\n"; + print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined print 'var time_js_next_test = (Date.now() + time_auto_update);'."\n"; ?> @@ -74,7 +74,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H if (arr.length > 0) { var audio = null; global->AGENDA_REMINDER_BROWSER_SOUND)) { + if (!empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav'.'\');'; } ?> diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php index e47c06cfd91..158c755935f 100644 --- a/htdocs/core/js/timepicker.js.php +++ b/htdocs/core/js/timepicker.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions for timepicker */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (! defined('NOLOGIN')) define('NOLOGIN', 1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -55,7 +55,7 @@ jQuery(function($){ timeFormat: 'HH:mm', amNames: ['AM', 'A'], pmNames: ['PM', 'P'], - isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?> + isRTL: trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?> }; $.timepicker.setDefaults($.timepicker.regional['defaultlang ?>']); }); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 0200fbc5b91..21682a4abe6 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -53,12 +53,12 @@ function accounting_prepare_head(AccountingAccount $object) global $langs, $conf; $h = 0; - $head = array (); + $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -96,18 +96,18 @@ function length_accountg($account) if ($account < 0 || is_empty($account)) return ''; - if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; + if (!is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT; - if (! is_empty($g)) { + if (!is_empty($g)) { // Clean parameters $i = strlen($account); if ($i >= 1) { - while ( $i < $g ) { + while ($i < $g) { $account .= '0'; - $i ++; + $i++; } return $account; @@ -131,18 +131,18 @@ function length_accounta($accounta) if ($accounta < 0 || is_empty($accounta)) return ''; - if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; + if (!is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; - if (! is_empty($a)) { + if (!is_empty($a)) { // Clean parameters $i = strlen($accounta); if ($i >= 1) { - while ( $i < $a ) { + while ($i < $a) { $accounta .= '0'; - $i ++; + $i++; } return $accounta; @@ -177,10 +177,10 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build print "\n\n\n"; - if(! is_empty($varlink)) $varlink = '?'.$varlink; + if (!is_empty($varlink)) $varlink = '?'.$varlink; - $head=array(); - $h=0; + $head = array(); + $h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("Journalization"); $head[$h][2] = 'journal'; @@ -190,7 +190,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build dol_fiche_head($head, 'journal'); - foreach($moreparam as $key => $value) + foreach ($moreparam as $key => $value) { print ''; } @@ -209,7 +209,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build { print ''; print ''.$langs->trans("CalculationMode").''; - if (! $variante) print ''; + if (!$variante) print ''; else print ''; print $calcmode; if ($variante) print ''.$variante; @@ -220,7 +220,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build // Ligne de la periode d'analyse du rapport print ''; print ''.$langs->trans("ReportPeriod").''; - if (! $periodlink) print ''; + if (!$periodlink) print ''; else print ''; if ($period) print $period; if ($periodlink) print ''.$periodlink; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index e5d7422cf8a..f2833c98e62 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -54,17 +54,17 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $langs->load("companies"); - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); // Filters //print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
'; @@ -79,15 +79,15 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("ActionsToDoBy").'   '; print ''; - print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").'   '; - print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); + print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or").' '.$langs->trans("ToUserOfGroup").'   '; + print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit); print ''; if ($conf->resource->enabled) { - include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; - $formresource=new FormResource($db); + include_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; + $formresource = new FormResource($db); // Resource print ''; @@ -103,16 +103,16 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("Type"); print '  '; - $multiselect=0; - if (! empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" + $multiselect = 0; + if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) // We use an option here because it adds bugs when used on agenda page "peruser" and "list" { - $multiselect=(!empty($conf->global->AGENDA_USE_EVENT_TYPE)); + $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } - print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect); + print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect); print ''; } - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) + if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { print ''; print ''; @@ -122,20 +122,20 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); print ''; print ''; print $langs->trans("Project").'   '; print ''; - print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ''; } - if ($canedit && ! preg_match('/list/', $_SERVER["PHP_SELF"])) + if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) { // Status print ''; @@ -188,7 +188,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print '
'; print '
'; - print ''; + print ''; print '
'; print '
'; @@ -196,7 +196,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if ($conf->browser->layout == 'phone') print '
'; else print ''; - print '
'; // Close fichecenter + print '
'; // Close fichecenter print '
'; //print ''; @@ -213,26 +213,26 @@ function show_array_actions_to_do($max = 5) { global $langs, $conf, $user, $db, $bc, $socid; - $now=dol_now(); + $now = dol_now(); include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent,"; - $sql.= " c.code, c.libelle as type_label,"; - $sql.= " s.nom as sname, s.rowid, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE a.entity = ".$conf->entity; - $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; - 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.= " ORDER BY a.datep DESC, a.id DESC"; - $sql.= $db->plimit($max, 0); + $sql .= " c.code, c.libelle as type_label,"; + $sql .= " s.nom as sname, s.rowid, s.client"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; + $sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE a.entity = ".$conf->entity; + $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; + 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 .= " ORDER BY a.datep DESC, a.id DESC"; + $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -246,8 +246,8 @@ function show_array_actions_to_do($max = 5) $var = true; $i = 0; - $staticaction=new ActionComm($db); - $customerstatic=new Client($db); + $staticaction = new ActionComm($db); + $customerstatic = new Client($db); while ($i < $num) { @@ -256,9 +256,9 @@ function show_array_actions_to_do($max = 5) print ''; - $staticaction->type_code=$obj->code; - $staticaction->label=($obj->label?$obj->label:$obj->type_label); - $staticaction->id=$obj->id; + $staticaction->type_code = $obj->code; + $staticaction->label = ($obj->label ? $obj->label : $obj->type_label); + $staticaction->id = $obj->id; print ''.$staticaction->getNomUrl(1, 34).''; // print ''.dol_trunc($obj->label,22).''; @@ -266,23 +266,23 @@ function show_array_actions_to_do($max = 5) print ''; if ($obj->rowid > 0) { - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; + $customerstatic->id = $obj->rowid; + $customerstatic->name = $obj->sname; + $customerstatic->client = $obj->client; print $customerstatic->getNomUrl(1, '', 16); } print ''; - $datep=$db->jdate($obj->dp); - $datep2=$db->jdate($obj->dp2); + $datep = $db->jdate($obj->dp); + $datep2 = $db->jdate($obj->dp2); // Date print ''.dol_print_date($datep, 'day').' '; - $late=0; - if ($obj->percent == 0 && $datep && $datep < time()) $late=1; - if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && ! $datep2 && $datep && $datep < time()) $late=1; + $late = 0; + if ($obj->percent == 0 && $datep && $datep < time()) $late = 1; + if ($obj->percent == 0 && !$datep && $datep2 && $datep2 < time()) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && !$datep2 && $datep && $datep < time()) $late = 1; if ($late) print img_warning($langs->trans("Late")); print ""; @@ -314,23 +314,23 @@ function show_array_last_actions_done($max = 5) { global $langs, $conf, $user, $db, $bc, $socid; - $now=dol_now(); + $now = dol_now(); $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; - $sql.= " c.code, c.libelle,"; - $sql.= " s.rowid, s.nom as sname, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; - $sql.= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE a.entity = ".$conf->entity; - $sql.= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; - 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 .= " c.code, c.libelle,"; + $sql .= " s.rowid, s.nom as sname, s.client"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a LEFT JOIN "; + $sql .= " ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE a.entity = ".$conf->entity; + $sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; + 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 .= " ORDER BY a.datep2 DESC"; $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -343,8 +343,8 @@ function show_array_last_actions_done($max = 5) $var = true; $i = 0; - $staticaction=new ActionComm($db); - $customerstatic=new Societe($db); + $staticaction = new ActionComm($db); + $customerstatic = new Societe($db); while ($i < $num) { @@ -353,9 +353,9 @@ function show_array_last_actions_done($max = 5) print ''; - $staticaction->type_code=$obj->code; - $staticaction->libelle=$obj->label; - $staticaction->id=$obj->id; + $staticaction->type_code = $obj->code; + $staticaction->libelle = $obj->label; + $staticaction->id = $obj->id; print ''.$staticaction->getNomUrl(1, 34).''; //print ''.dol_trunc($obj->label,24).''; @@ -363,9 +363,9 @@ function show_array_last_actions_done($max = 5) print ''; if ($obj->rowid > 0) { - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; + $customerstatic->id = $obj->rowid; + $customerstatic->name = $obj->sname; + $customerstatic->client = $obj->client; print $customerstatic->getNomUrl(1, '', 24); } print ''; @@ -467,13 +467,13 @@ function actions_prepare_head($object) if ($conf->resource->enabled) { include_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; - $resource=new DolResource($db); + $resource = new DolResource($db); $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; $listofresourcelinked = $resource->getElementResources($object->element, $object->id); - $nbResources=(is_array($listofresourcelinked)?count($listofresourcelinked):0); + $nbResources = (is_array($listofresourcelinked) ?count($listofresourcelinked) : 0); $head[$h][1] = $langs->trans("Resources"); - if ($nbResources > 0) $head[$h][1].= ''.($nbResources).''; + if ($nbResources > 0) $head[$h][1] .= ''.($nbResources).''; $head[$h][2] = 'resources'; $h++; } @@ -481,12 +481,12 @@ function actions_prepare_head($object) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->agenda->dir_output . "/" . $object->id; + $upload_dir = $conf->agenda->dir_output."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -516,30 +516,30 @@ function calendars_prepare_head($param) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/list.php'.($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/list.php'.($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("ViewList"); $head[$h][2] = 'cardlist'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_month'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewCal"); $head[$h][2] = 'cardmonth'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_week'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_week'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewWeek"); $head[$h][2] = 'cardweek'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param?'&'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/index.php?action=show_day'.($param ? '&'.$param : ''); $head[$h][1] = $langs->trans("ViewDay"); $head[$h][2] = 'cardday'; $h++; //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - if (! empty($conf->global->AGENDA_SHOW_PERTYPE)) + if (!empty($conf->global->AGENDA_SHOW_PERTYPE)) { - $head[$h][0] = DOL_URL_ROOT.'/comm/action/pertype.php'.($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/pertype.php'.($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("ViewPerType"); $head[$h][2] = 'cardpertype'; $h++; @@ -547,7 +547,7 @@ function calendars_prepare_head($param) $newparam = $param; $newparam = preg_replace('/&?search_filtert=\d+/', '', $newparam); - $head[$h][0] = DOL_URL_ROOT.'/comm/action/peruser.php'.($newparam?'?'.$newparam:''); + $head[$h][0] = DOL_URL_ROOT.'/comm/action/peruser.php'.($newparam ? '?'.$newparam : ''); $head[$h][1] = $langs->trans("ViewPerUser"); $head[$h][2] = 'cardperuser'; $h++; diff --git a/htdocs/core/lib/asset.lib.php b/htdocs/core/lib/asset.lib.php index 5c6bac579f2..1b58784f6e8 100644 --- a/htdocs/core/lib/asset.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -35,7 +35,7 @@ function asset_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/setup.php'; $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; @@ -50,12 +50,12 @@ function asset_admin_prepare_head() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin'); - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_type_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); $head[$h][2] = 'attributes_type'; $h++; @@ -80,7 +80,7 @@ function asset_prepare_head(Asset $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; + $head[$h][0] = DOL_URL_ROOT.'/asset/card.php'; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -97,25 +97,25 @@ function asset_prepare_head(Asset $object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->assets->dir_output . '/' . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->assets->dir_output.'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/asset/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -135,7 +135,7 @@ function asset_type_prepare_head(AssetType $object) { global $langs, $conf, $user; - $h=0; + $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 1a7b33569ce..a4d7a077aab 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -27,18 +27,18 @@ /* ******************************************************************** */ /* COLORS */ /* ******************************************************************** */ -$bar_color=array(0,0,0); -$bg_color=array(255,255,255); -$text_color=array(0,0,0); +$bar_color = array(0, 0, 0); +$bg_color = array(255, 255, 255); +$text_color = array(0, 0, 0); /* ******************************************************************** */ /* FONT FILE */ /* ******************************************************************** */ -if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc=constant('DOL_DEFAULT_TTF_BOLD'); +if (defined('DOL_DEFAULT_TTF_BOLD')) $font_loc = constant('DOL_DEFAULT_TTF_BOLD'); // Automatic-Detection of Font if running Windows // @CHANGE LDR -if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc=$_SERVER['WINDIR'].'\Fonts\arialbd.ttf'; +if (isset($_SERVER['WINDIR']) && @file_exists($_SERVER['WINDIR'])) $font_loc = $_SERVER['WINDIR'].'\Fonts\arialbd.ttf'; if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path to a TTF font.'); @@ -50,7 +50,7 @@ if (empty($font_loc)) die('DOL_DEFAULT_TTF_BOLD must de defined with full path t * genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN */ -if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc=constant('PHP-BARCODE_PATH_COMMAND'); +if (defined('PHP-BARCODE_PATH_COMMAND')) $genbarcode_loc = constant('PHP-BARCODE_PATH_COMMAND'); else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION; @@ -69,16 +69,16 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png") { dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode"); - $bars=barcode_encode($code, $encoding); - if (! $bars || ! empty($bars['error'])) + $bars = barcode_encode($code, $encoding); + if (!$bars || !empty($bars['error'])) { // Return error message instead of array - if (empty($bars['error'])) $error='Bad Value '.$code.' for encoding '.$encoding; - else $error=$bars['error']; + if (empty($bars['error'])) $error = 'Bad Value '.$code.' for encoding '.$encoding; + else $error = $bars['error']; dol_syslog('barcode.lib.php::barcode_print '.$error, LOG_ERR); return $error; } - if (! $mode) $mode="png"; + if (!$mode) $mode = "png"; //if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']); //elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0); //else @@ -116,23 +116,23 @@ function barcode_encode($code, $encoding) (preg_match("/^ean$/i", $encoding)) || (($encoding) && (preg_match("/^isbn$/i", $encoding)) - && (( strlen($code)==9 || strlen($code)==10) || - (((preg_match("/^978/", $code) && strlen($code)==12) || - (strlen($code)==13))))) + && ((strlen($code) == 9 || strlen($code) == 10) || + (((preg_match("/^978/", $code) && strlen($code) == 12) || + (strlen($code) == 13))))) - || (( !isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding) )) + || ((!isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding))) && (preg_match("/^[0-9]{12,13}$/", $code))) ) { /* use built-in EAN-Encoder */ dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean"); - $bars=barcode_encode_ean($code, $encoding); + $bars = barcode_encode_ean($code, $encoding); } elseif (file_exists($genbarcode_loc)) // For example C39 { /* use genbarcode */ dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding); - $bars=barcode_encode_genbarcode($code, $encoding); + $bars = barcode_encode_genbarcode($code, $encoding); } else { @@ -160,14 +160,14 @@ function barcode_encode($code, $encoding) */ function barcode_gen_ean_sum($ean) { - $even=true; $esum=0; $osum=0; - $ln=strlen($ean)-1; - for ($i=$ln; $i>=0; $i--) + $even = true; $esum = 0; $osum = 0; + $ln = strlen($ean) - 1; + for ($i = $ln; $i >= 0; $i--) { - if ($even) $esum+=$ean[$i]; else $osum+=$ean[$i]; - $even=!$even; + if ($even) $esum += $ean[$i]; else $osum += $ean[$i]; + $even = !$even; } - return (10-((3*$esum+$osum)%10))%10; + return (10 - ((3 * $esum + $osum) % 10)) % 10; } /** @@ -179,48 +179,48 @@ function barcode_gen_ean_sum($ean) */ function barcode_encode_ean($ean, $encoding = "EAN-13") { - $digits=array(3211,2221,2122,1411,1132,1231,1114,1312,1213,3112); - $mirror=array("000000","001011","001101","001110","010011","011001","011100","010101","010110","011010"); - $guards=array("9a1a","1a1a1","a1a"); + $digits = array(3211, 2221, 2122, 1411, 1132, 1231, 1114, 1312, 1213, 3112); + $mirror = array("000000", "001011", "001101", "001110", "010011", "011001", "011100", "010101", "010110", "011010"); + $guards = array("9a1a", "1a1a1", "a1a"); - $ean=trim($ean); + $ean = trim($ean); if (preg_match("/[^0-9]/i", $ean)) { return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)"); } - $encoding=strtoupper($encoding); - if ($encoding=="ISBN") + $encoding = strtoupper($encoding); + if ($encoding == "ISBN") { - if (!preg_match("/^978/", $ean)) $ean="978".$ean; + if (!preg_match("/^978/", $ean)) $ean = "978".$ean; } - if (preg_match("/^978/", $ean)) $encoding="ISBN"; - if (strlen($ean)<12 || strlen($ean)>13) + if (preg_match("/^978/", $ean)) $encoding = "ISBN"; + if (strlen($ean) < 12 || strlen($ean) > 13) { return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)"); } - $ean=substr($ean, 0, 12); - $eansum=barcode_gen_ean_sum($ean); - $ean.=$eansum; - $line=$guards[0]; - for ($i=1;$i<13;$i++) + $ean = substr($ean, 0, 12); + $eansum = barcode_gen_ean_sum($ean); + $ean .= $eansum; + $line = $guards[0]; + for ($i = 1; $i < 13; $i++) { - $str=$digits[$ean[$i]]; - if ($i<7 && $mirror[$ean[0]][$i-1]==1) $line.=strrev($str); else $line.=$str; - if ($i==6) $line.=$guards[1]; + $str = $digits[$ean[$i]]; + if ($i < 7 && $mirror[$ean[0]][$i - 1] == 1) $line .= strrev($str); else $line .= $str; + if ($i == 6) $line .= $guards[1]; } - $line.=$guards[2]; + $line .= $guards[2]; /* create text */ - $pos=0; - $text=""; - for ($a=0;$a<13;$a++) + $pos = 0; + $text = ""; + for ($a = 0; $a < 13; $a++) { - if ($a>0) $text.=" "; - $text.="$pos:12:{$ean[$a]}"; - if ($a==0) $pos+=12; - elseif ($a==6) $pos+=12; - else $pos+=7; + if ($a > 0) $text .= " "; + $text .= "$pos:12:{$ean[$a]}"; + if ($a == 0) $pos += 12; + elseif ($a == 6) $pos += 12; + else $pos += 7; } return array( @@ -243,25 +243,25 @@ function barcode_encode_genbarcode($code, $encoding) global $genbarcode_loc; // Clean parameters - if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code, 0, 12); - if (!$encoding) $encoding="ANY"; - $encoding=preg_replace("/[\\\|]/", "_", $encoding); - $code=preg_replace("/[\\\|]/", "_", $code); + if (preg_match("/^ean$/i", $encoding) && strlen($code) == 13) $code = substr($code, 0, 12); + if (!$encoding) $encoding = "ANY"; + $encoding = preg_replace("/[\\\|]/", "_", $encoding); + $code = preg_replace("/[\\\|]/", "_", $code); - $command=escapeshellarg($genbarcode_loc); + $command = escapeshellarg($genbarcode_loc); //$paramclear=" \"".str_replace("\"", "\\\"",$code)."\" \"".str_replace("\"", "\\\"",strtoupper($encoding))."\""; - $paramclear=" ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding)); + $paramclear = " ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding)); - $fullcommandclear=$command." ".$paramclear." 2>&1"; + $fullcommandclear = $command." ".$paramclear." 2>&1"; //print $fullcommandclear."
\n";exit; dol_syslog("Run command ".$fullcommandclear); - $fp=popen($fullcommandclear, "r"); + $fp = popen($fullcommandclear, "r"); if ($fp) { - $bars=fgets($fp, 1024); - $text=fgets($fp, 1024); - $encoding=fgets($fp, 1024); + $bars = fgets($fp, 1024); + $text = fgets($fp, 1024); + $encoding = fgets($fp, 1024); pclose($fp); } else @@ -270,7 +270,7 @@ function barcode_encode_genbarcode($code, $encoding) return false; } //var_dump($bars); - $ret=array( + $ret = array( "bars" => trim($bars), "text" => trim($text), "encoding" => trim($encoding), @@ -279,7 +279,7 @@ function barcode_encode_genbarcode($code, $encoding) //var_dump($ret); if (preg_match('/permission denied/i', $ret['bars'])) { - $ret['error']=$ret['bars']; $ret['bars']=''; + $ret['error'] = $ret['bars']; $ret['bars'] = ''; return $ret; } if (!$ret['bars']) return false; @@ -310,99 +310,99 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, //var_dump($font_loc); /* set defaults */ - if ($scale<1) $scale=2; - $total_y=(int) $total_y; - if ($total_y<1) $total_y=(int) $scale * 60; + if ($scale < 1) $scale = 2; + $total_y = (int) $total_y; + if ($total_y < 1) $total_y = (int) $scale * 60; if (!$space) - $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale); + $space = array('top'=>2 * $scale, 'bottom'=>2 * $scale, 'left'=>2 * $scale, 'right'=>2 * $scale); /* count total width */ - $xpos=0; - $width=true; - $ln=strlen($bars); - for ($i=0; $i<$ln; $i++) + $xpos = 0; + $width = true; + $ln = strlen($bars); + for ($i = 0; $i < $ln; $i++) { - $val=strtolower($bars[$i]); + $val = strtolower($bars[$i]); if ($width) { - $xpos+=$val*$scale; - $width=false; + $xpos += $val * $scale; + $width = false; continue; } if (preg_match("/[a-z]/", $val)) { /* tall bar */ - $val=ord($val)-ord('a')+1; + $val = ord($val) - ord('a') + 1; } - $xpos+=$val*$scale; - $width=true; + $xpos += $val * $scale; + $width = true; } /* allocate the image */ - $total_x=( $xpos )+$space['right']+$space['right']; - $xpos=$space['left']; - if (! function_exists("imagecreate")) + $total_x = ($xpos) + $space['right'] + $space['right']; + $xpos = $space['left']; + if (!function_exists("imagecreate")) { print "You don't have the gd2 extension enabled
\n"; return ""; } - $im=imagecreate($total_x, $total_y); + $im = imagecreate($total_x, $total_y); /* create two images */ - $col_bg=ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]); - $col_bar=ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]); - $col_text=ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]); - $height=round($total_y-($scale*10)); - $height2=round($total_y-$space['bottom']); + $col_bg = ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]); + $col_bar = ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]); + $col_text = ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]); + $height = round($total_y - ($scale * 10)); + $height2 = round($total_y - $space['bottom']); /* paint the bars */ - $width=true; - $ln=strlen($bars); - for ($i=0; $i<$ln; $i++) + $width = true; + $ln = strlen($bars); + for ($i = 0; $i < $ln; $i++) { - $val=strtolower($bars[$i]); + $val = strtolower($bars[$i]); if ($width) { - $xpos+=$val*$scale; - $width=false; + $xpos += $val * $scale; + $width = false; continue; } if (preg_match("/[a-z]/", $val)) { /* tall bar */ - $val=ord($val)-ord('a')+1; - $h=$height2; - } else $h=$height; - imagefilledrectangle($im, $xpos, $space['top'], $xpos+($val*$scale)-1, $h, $col_bar); - $xpos+=$val*$scale; - $width=true; + $val = ord($val) - ord('a') + 1; + $h = $height2; + } else $h = $height; + imagefilledrectangle($im, $xpos, $space['top'], $xpos + ($val * $scale) - 1, $h, $col_bar); + $xpos += $val * $scale; + $width = true; } - $chars=explode(" ", $text); + $chars = explode(" ", $text); reset($chars); - while (list($n, $v)=each($chars)) + while (list($n, $v) = each($chars)) { if (trim($v)) { - $inf=explode(":", $v); - $fontsize=$scale*($inf[1]/1.8); - $fontheight=$total_y-($fontsize/2.7)+2; - imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2, $fontheight, $col_text, $font_loc, $inf[2]); + $inf = explode(":", $v); + $fontsize = $scale * ($inf[1] / 1.8); + $fontheight = $total_y - ($fontsize / 2.7) + 2; + imagettftext($im, $fontsize, 0, $space['left'] + ($scale * $inf[0]) + 2, $fontheight, $col_text, $font_loc, $inf[2]); } } /* output the image */ - $mode=strtolower($mode); - if ($mode=='jpg' || $mode=='jpeg') + $mode = strtolower($mode); + if ($mode == 'jpg' || $mode == 'jpeg') { header("Content-Type: image/jpeg; name=\"barcode.jpg\""); imagejpeg($im); } - elseif ($mode=='gif') + elseif ($mode == 'gif') { header("Content-Type: image/gif; name=\"barcode.gif\""); imagegif($im); } - elseif (! empty($filebarcode)) // To wxrite into afile onto disk + elseif (!empty($filebarcode)) // To wxrite into afile onto disk { imagepng($im, $filebarcode); } diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index ca665637768..37ff7acad44 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -49,7 +49,7 @@ function categories_prepare_head($object, $type) $head[$h][2] = 'photos'; $h++; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type; $head[$h][1] = $langs->trans("Translation"); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index eac9f404188..16d29af4a35 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -105,7 +105,7 @@ function societe_prepare_head(Societe $object) } } $supplier_module_enabled = 0; - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled=1; + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $supplier_module_enabled = 1; if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 0082947d0c1..8edc81d7ee7 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -42,8 +42,8 @@ function contact_prepare_head(Contact $object) $head[$tab][2] = 'card'; $tab++; - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); @@ -59,7 +59,7 @@ function contact_prepare_head(Contact $object) $tab++; // Related items - if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled)) + if (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || !empty($conf->fournisseur->enabled)) { $head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id; $head[$tab][1] = $langs->trans("Referers"); @@ -75,32 +75,32 @@ function contact_prepare_head(Contact $object) // Notes if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; $head[$tab][1] = $langs->trans("Note"); - if($nbNote > 0) $head[$tab][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$tab][1] .= ''.$nbNote.''; $head[$tab][2] = 'note'; $tab++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->societe->dir_output."/contact/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; // Agenda / Events $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; - $head[$tab][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$tab][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$tab][1].= '/'; - $head[$tab][1].= $langs->trans("Agenda"); + $head[$tab][1] .= '/'; + $head[$tab][1] .= $langs->trans("Agenda"); } $head[$tab][2] = 'agenda'; $tab++; diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index ec91a2dcc70..b7d3c45bee3 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -45,7 +45,7 @@ function contract_prepare_head(Contrat $object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -59,32 +59,32 @@ function contract_prepare_head(Contrat $object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index e7043a1798a..0dd8aeb1a32 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -33,7 +33,7 @@ */ function get_tz_array() { - $tzarray=array( + $tzarray = array( -11=>"Pacific/Midway", -10=>"Pacific/Fakaofo", -9=>"America/Anchorage", @@ -85,22 +85,22 @@ function getServerTimeZoneInt($refgmtdate = 'now') if (method_exists('DateTimeZone', 'getOffset')) { // Method 1 (include daylight) - $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow, '%Y'); $monthref=dol_print_date($gmtnow, '%m'); $dayref=dol_print_date($gmtnow, '%d'); - if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; - elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01'; - else $newrefgmtdate=$yearref.'-01-01'; - $newrefgmtdate.='T00:00:00+00:00'; + $gmtnow = dol_now('gmt'); $yearref = dol_print_date($gmtnow, '%Y'); $monthref = dol_print_date($gmtnow, '%m'); $dayref = dol_print_date($gmtnow, '%d'); + if ($refgmtdate == 'now') $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref; + elseif ($refgmtdate == 'summer') $newrefgmtdate = $yearref.'-08-01'; + else $newrefgmtdate = $yearref.'-01-01'; + $newrefgmtdate .= 'T00:00:00+00:00'; $localtz = new DateTimeZone(getServerTimeZoneString()); $localdt = new DateTime($newrefgmtdate, $localtz); - $tmp=-1*$localtz->getOffset($localdt); + $tmp = -1 * $localtz->getOffset($localdt); //print $refgmtdate.'='.$tmp; } else { - $tmp=0; + $tmp = 0; dol_print_error('', 'PHP version must be 5.3+'); } - $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); + $tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600)); return $tz; } @@ -118,23 +118,23 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit) global $conf; if ($duration_value == 0) return $time; - if ($duration_unit == 'h') return $time + (3600*$duration_value); - if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); + if ($duration_unit == 'h') return $time + (3600 * $duration_value); + if ($duration_unit == 'w') return $time + (3600 * 24 * 7 * $duration_value); - $deltastring='P'; + $deltastring = 'P'; - if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; } - if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; } - if ($duration_unit == 'd') { $deltastring.="D"; } - if ($duration_unit == 'm') { $deltastring.="M"; } - if ($duration_unit == 'y') { $deltastring.="Y"; } + if ($duration_value > 0) { $deltastring .= abs($duration_value); $sub = false; } + if ($duration_value < 0) { $deltastring .= abs($duration_value); $sub = true; } + if ($duration_unit == 'd') { $deltastring .= "D"; } + if ($duration_unit == 'm') { $deltastring .= "M"; } + if ($duration_unit == 'y') { $deltastring .= "Y"; } $date = new DateTime(); - if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); + if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); $date->setTimestamp($time); $interval = new DateInterval($deltastring); - if($sub) $date->sub($interval); + if ($sub) $date->sub($interval); else $date->add($interval); return $date->getTimestamp(); @@ -152,7 +152,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit) */ function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) { - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; + $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds; return $iResult; } @@ -182,26 +182,26 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l { global $langs; - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days + if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours + if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec') { - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US + if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US - $sTime=''; - $sDay=0; - $sWeek=0; + $sTime = ''; + $sDay = 0; + $sWeek = 0; if ($iSecond >= $lengthOfDay) { - for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) + for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) { $sDay++; - $iSecond-=$lengthOfDay; + $iSecond -= $lengthOfDay; } $dayTranslate = $langs->trans("Day"); - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); + if ($iSecond >= ($lengthOfDay * 2)) $dayTranslate = $langs->trans("Days"); } if ($lengthOfWeek < 7) @@ -210,70 +210,70 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l { if ($sDay >= $lengthOfWeek) { - $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); + $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek); $sDay = $sDay % $lengthOfWeek; $weekTranslate = $langs->trans("DurationWeek"); if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); - $sTime.=$sWeek.' '.$weekTranslate.' '; + $sTime .= $sWeek.' '.$weekTranslate.' '; } } } - if ($sDay>0) + if ($sDay > 0) { $dayTranslate = $langs->trans("Day"); if ($sDay > 1) $dayTranslate = $langs->trans("Days"); - $sTime.=$sDay.' '.$dayTranslate.' '; + $sTime .= $sDay.' '.$dayTranslate.' '; } if ($format == 'all') { if ($iSecond || empty($sDay)) { - $sTime.= dol_print_date($iSecond, 'hourduration', true); + $sTime .= dol_print_date($iSecond, 'hourduration', true); } } elseif ($format == 'allhourminsec') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60))); } elseif ($format == 'allhourmin') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))); } elseif ($format == 'allhour') { - return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))); } } elseif ($format == 'hour') // only hour part { - $sTime=dol_print_date($iSecond, '%H', true); + $sTime = dol_print_date($iSecond, '%H', true); } elseif ($format == 'fullhour') { if (!empty($iSecond)) { - $iSecond=$iSecond/3600; + $iSecond = $iSecond / 3600; } else { - $iSecond=0; + $iSecond = 0; } - $sTime=$iSecond; + $sTime = $iSecond; } elseif ($format == 'min') // only min part { - $sTime=dol_print_date($iSecond, '%M', true); + $sTime = dol_print_date($iSecond, '%M', true); } elseif ($format == 'sec') // only sec part { - $sTime=dol_print_date($iSecond, '%S', true); + $sTime = dol_print_date($iSecond, '%S', true); } elseif ($format == 'month') // only month part { - $sTime=dol_print_date($iSecond, '%m', true); + $sTime = dol_print_date($iSecond, '%m', true); } elseif ($format == 'year') // only year part { - $sTime=dol_print_date($iSecond, '%Y', true); + $sTime = dol_print_date($iSecond, '%Y', true); } return trim($sTime); } @@ -292,19 +292,19 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0) { global $db; - $sqldate=""; + $sqldate = ""; if ($month_date > 0) { if ($year_date > 0 && empty($day_date)) { - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; - } elseif ($year_date > 0 && ! empty($day_date)) { - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); - $sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); + $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; + } elseif ($year_date > 0 && !empty($day_date)) { + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); + $sqldate .= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; } else - $sqldate.= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; - } elseif ($year_date > 0){ - $sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; + $sqldate .= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; + } elseif ($year_date > 0) { + $sqldate .= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); + $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; } return $sqldate; } @@ -330,7 +330,7 @@ function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $exclu */ function dol_stringtotime($string, $gm = 1) { - $reg=array(); + $reg = array(); // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) { @@ -343,9 +343,9 @@ function dol_stringtotime($string, $gm = 1) $shour = $reg[4]; $smin = $reg[5]; $ssec = $reg[6]; - if ($syear < 50) $syear+=1900; - if ($syear >= 50 && $syear < 100) $syear+=2000; - $string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); + if ($syear < 50) $syear += 1900; + if ($syear >= 50 && $syear < 100) $syear += 2000; + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); } elseif ( preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339) @@ -359,12 +359,12 @@ function dol_stringtotime($string, $gm = 1) $shour = $reg[4]; $smin = $reg[5]; $ssec = $reg[6]; - $string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); } - $string=preg_replace('/([^0-9])/i', '', $string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm?1:0)); + $string = preg_replace('/([^0-9])/i', '', $string); + $tmp = $string.'000000'; + $date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0)); return $date; } @@ -378,9 +378,9 @@ function dol_stringtotime($string, $gm = 1) */ function dol_get_prev_day($day, $month, $year) { - $time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); - $time-=24*60*60; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); + $time -= 24 * 60 * 60; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -393,9 +393,9 @@ function dol_get_prev_day($day, $month, $year) */ function dol_get_next_day($day, $month, $year) { - $time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); - $time+=24*60*60; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); + $time += 24 * 60 * 60; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -414,7 +414,7 @@ function dol_get_prev_month($month, $year) } else { - $prev_month = $month-1; + $prev_month = $month - 1; $prev_year = $year; } return array('year' => $prev_year, 'month' => $prev_month); @@ -453,9 +453,9 @@ function dol_get_prev_week($day, $week, $month, $year) { $tmparray = dol_get_first_day_week($day, $month, $year); - $time=dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0); - $time-=24*60*60*7; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0); + $time -= 24 * 60 * 60 * 7; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -471,9 +471,9 @@ function dol_get_next_week($day, $week, $month, $year) { $tmparray = dol_get_first_day_week($day, $month, $year); - $time=dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0); - $time+=24*60*60*7; - $tmparray=dol_getdate($time, true); + $time = dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0); + $time += 24 * 60 * 60 * 7; + $tmparray = dol_getdate($time, true); return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); } @@ -515,7 +515,7 @@ function dol_get_last_day($year, $month = 12, $gm = false) } // On se deplace au debut du mois suivant, et on retire un jour - $datelim=dol_mktime(23, 59, 59, $month, 1, $year, $gm); + $datelim = dol_mktime(23, 59, 59, $month, 1, $year, $gm); $datelim -= (3600 * 24); return $datelim; @@ -537,57 +537,57 @@ function dol_get_first_day_week($day, $month, $year, $gm = false) $date = dol_mktime(0, 0, 0, $month, $day, $year, $gm); //Checking conf of start week - $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); + $start_week = (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1); - $tmparray = dol_getdate($date, true); // detail of current day + $tmparray = dol_getdate($date, true); // detail of current day //Calculate days = offset from current day $days = $start_week - $tmparray['wday']; - if ($days>=1) $days=7-$days; + if ($days >= 1) $days = 7 - $days; $days = abs($days); - $seconds = $days*24*60*60; + $seconds = $days * 24 * 60 * 60; //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'
'; //Get first day of week - $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters + $tmpdaytms = date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters $tmpday = date("d", $tmpdaytms); //Check first day of week is in same month than current day or not - if ($tmpday>$day) + if ($tmpday > $day) { - $prev_month = $month-1; - $prev_year = $year; + $prev_month = $month - 1; + $prev_year = $year; - if ($prev_month==0) + if ($prev_month == 0) { $prev_month = 12; - $prev_year = $year-1; + $prev_year = $year - 1; } } else { $prev_month = $month; - $prev_year = $year; + $prev_year = $year; } $tmpmonth = $prev_month; $tmpyear = $prev_year; //Get first day of next week - $tmptime=dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0); - $tmptime-=24*60*60*7; - $tmparray=dol_getdate($tmptime, true); - $prev_day = $tmparray['mday']; + $tmptime = dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0); + $tmptime -= 24 * 60 * 60 * 7; + $tmparray = dol_getdate($tmptime, true); + $prev_day = $tmparray['mday']; //Check prev day of week is in same month than first day or not if ($prev_day > $tmpday) { - $prev_month = $month-1; - $prev_year = $year; + $prev_month = $month - 1; + $prev_year = $year; - if ($prev_month==0) + if ($prev_month == 0) { $prev_month = 12; - $prev_year = $year-1; + $prev_year = $year - 1; } } @@ -626,11 +626,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if ($includesunday < 0) $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); - $i=0; - while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) + $i = 0; + while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd)) && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) { - $ferie=false; + $ferie = false; $jour = date("d", $timestampStart); $mois = date("m", $timestampStart); @@ -638,19 +638,19 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... // Do not use this anymore, use instead the dictionary of public holidays. - if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) + if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) { - $arrayofdaystring=explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); - foreach($arrayofdaystring as $daystring) + $arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); + foreach ($arrayofdaystring as $daystring) { - $tmp=explode('-', $daystring); + $tmp = explode('-', $daystring); if ($tmp[2]) { - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true; } else { - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; + if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true; } } } @@ -659,26 +659,26 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', // Loop on public holiday defined into hrm_public_holiday $sql = "SELECT code, entity, fk_country, dayrule, year, month, day, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday"; - $sql.= " WHERE active = 1 and fk_country IN (0".($country_id > 0 ? ", ".$country_id : 0).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday"; + $sql .= " WHERE active = 1 and fk_country IN (0".($country_id > 0 ? ", ".$country_id : 0).")"; $resql = $db->query($sql); if ($resql) { $num_rows = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num_rows) { $obj = $db->fetch_object($resql); - if (! empty($obj->dayrule) && $obj->dayrule != 'date') // For example 'easter', '...' + if (!empty($obj->dayrule) && $obj->dayrule != 'date') // For example 'easter', '...' { $specialdayrule[$obj->dayrule] = $obj->dayrule; } else { $match = 1; - if (! empty($obj->year) && $obj->year != $annee) $match = 0; + if (!empty($obj->year) && $obj->year != $annee) $match = 0; if ($obj->month != $mois) $match = 0; if ($obj->day != $jour) $match = 0; @@ -701,7 +701,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; // Easter (sunday) } @@ -719,7 +719,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_lundi_ascension = date("d", $date_lundi_paques); $mois_lundi_ascension = date("m", $date_lundi_paques); - if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; + if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie = true; // Easter (monday) } @@ -737,7 +737,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; + if ($jour_ascension == $jour && $mois_ascension == $mois) $ferie = true; // Ascension (thursday) } @@ -755,7 +755,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; // "Pentecote" (sunday) } if (in_array('pentecotemonday', $specialdayrule)) @@ -772,7 +772,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; // "Pentecote" (monday) } @@ -785,12 +785,12 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), - date("d", $date_paques) -2, + date("d", $date_paques) - 2, date("Y", $date_paques) ); $jour_viernes = date("d", $date_viernes); $mois_viernes = date("m", $date_viernes); - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; + if ($jour_viernes == $jour && $mois_viernes == $mois) $ferie = true; //Viernes Santo } @@ -808,7 +808,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', ); $jour_fronleichnam = date("d", $date_fronleichnam); $mois_fronleichnam = date("m", $date_fronleichnam); - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; + if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie = true; // Fronleichnam } @@ -819,11 +819,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $jour_semaine = jddayofweek($jour_julien, 0); if ($includesaturday) //Saturday (6) and Sunday (0) { - if ($jour_semaine == 6) $ferie=true; + if ($jour_semaine == 6) $ferie = true; } if ($includesunday) //Saturday (6) and Sunday (0) { - if($jour_semaine == 0) $ferie=true; + if ($jour_semaine == 0) $ferie = true; } } @@ -831,7 +831,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if ($ferie) $nbFerie++; // Increase number of days (on go up into loop) - $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); + $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); $i++; @@ -862,7 +862,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0) { $bit = 1; } - $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; + $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit; } //print ($timestampEnd - $timestampStart) - $lastday; return $nbjours; @@ -882,15 +882,15 @@ function num_between_day($timestampStart, $timestampEnd, $lastday = 0) */ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '') { - global $langs,$mysoc; + global $langs, $mysoc; - if (empty($country_code)) $country_code=$mysoc->country_code; + if (empty($country_code)) $country_code = $mysoc->country_code; dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); // Check parameters - if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; - if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; + if (!is_int($timestampStart) && !is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; + if (!is_int($timestampEnd) && !is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; if ($timestampStart < $timestampEnd) @@ -898,14 +898,14 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); $nbOpenDay = $numdays - $numholidays; - $nbOpenDay.= " " . $langs->trans("Days"); - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); + $nbOpenDay .= " ".$langs->trans("Days"); + if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } elseif ($timestampStart == $timestampEnd) { - $nbOpenDay=$lastday; - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); + $nbOpenDay = $lastday; + if ($inhour == 1) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } else @@ -926,7 +926,7 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, */ function monthArray($outputlangs, $short = 0) { - $montharray = array ( + $montharray = array( 1 => $outputlangs->trans("Month01"), 2 => $outputlangs->trans("Month02"), 3 => $outputlangs->trans("Month03"), @@ -941,9 +941,9 @@ function monthArray($outputlangs, $short = 0) 12 => $outputlangs->trans("Month12") ); - if (! empty($short)) + if (!empty($short)) { - $montharray = array ( + $montharray = array( 1 => $outputlangs->trans("MonthShort01"), 2 => $outputlangs->trans("MonthShort02"), 3 => $outputlangs->trans("MonthShort03"), @@ -973,7 +973,7 @@ function getWeekNumbersOfMonth($month, $year) { $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); $TWeek = array(); - for($day = 1; $day < $nb_days; $day++) { + for ($day = 1; $day < $nb_days; $day++) { $week_number = getWeekNumber($day, $month, $year); $TWeek[$week_number] = $week_number; } @@ -990,8 +990,8 @@ function getWeekNumbersOfMonth($month, $year) function getFirstDayOfEachWeek($TWeek, $year) { $TFirstDayOfWeek = array(); - foreach($TWeek as $weekNb) { - if(in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année + foreach ($TWeek as $weekNb) { + if (in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++; //Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année $TFirstDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb)); } return $TFirstDayOfWeek; @@ -1007,7 +1007,7 @@ function getFirstDayOfEachWeek($TWeek, $year) function getLastDayOfEachWeek($TWeek, $year) { $TLastDayOfWeek = array(); - foreach($TWeek as $weekNb) { + foreach ($TWeek as $weekNb) { $TLastDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb.'+6 days')); } return $TLastDayOfWeek; diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 6840e81a646..38e847bb3c1 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -42,11 +42,11 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { global $db, $conf, $langs; - $idprod=$line->fk_product; - $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); - $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); - $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders - $note=(! empty($line->note)?$line->note:''); + $idprod = $line->fk_product; + $label = (!empty($line->label) ? $line->label : (!empty($line->libelle) ? $line->libelle : '')); + $desc = (!empty($line->desc) ? $line->desc : (!empty($line->description) ? $line->description : '')); + $ref_supplier = (!empty($line->ref_supplier) ? $line->ref_supplier : (!empty($line->ref_fourn) ? $line->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders + $note = (!empty($line->note) ? $line->note : ''); if ($issupplierline) $prodser = new ProductFournisseur($db); else $prodser = new Product($db); @@ -55,57 +55,57 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } // Description short of product line - $libelleproduitservice=$label; + $libelleproduitservice = $label; // Description long of product line if ($desc && ($desc != $label)) { if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); } elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); } elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($line->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { if ($idprod) { - if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); + if (empty($hidedesc)) $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } else { - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } @@ -118,7 +118,7 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu { $prefix_prodserv = ""; $ref_prodserv = ""; - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { if ($prodser->isService()) { @@ -132,34 +132,34 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu if (empty($hideref)) { - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref + if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref else $ref_prodserv = $prodser->ref; // Show local ref only $ref_prodserv .= " - "; } - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; + $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; } } - if (! empty($line->date_start) || ! empty($line->date_end)) + if (!empty($line->date_start) || !empty($line->date_end)) { - $format='day'; + $format = 'day'; // Show duration if exists if ($line->date_start && $line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; } - if ($line->date_start && ! $line->date_end) + if ($line->date_start && !$line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')'; } - if (! $line->date_start && $line->date_end) + if (!$line->date_start && $line->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $period); + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); //print $libelleproduitservice; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 16d7d3d8a97..b2280657481 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -33,10 +33,10 @@ function donation_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -44,7 +44,7 @@ function donation_admin_prepare_head() // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin'); - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; @@ -67,10 +67,10 @@ function donation_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; - $h ++; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -80,25 +80,25 @@ function donation_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->don->dir_output . '/' . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index a49e501af78..4dbb418855a 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -36,15 +36,15 @@ function ecm_prepare_dasboard_head($object) $h = 0; $head = array(); - $helptext =$langs->trans("ECMAreaDesc").'
'; - $helptext.=$langs->trans("ECMAreaDesc2"); + $helptext = $langs->trans("ECMAreaDesc").'
'; + $helptext .= $langs->trans("ECMAreaDesc2"); $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php'; $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); $head[$h][2] = 'index'; $h++; - if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) + if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php'; $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index cb4e5cf8b29..839be4c4e3d 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -39,16 +39,16 @@ function emailing_prepare_head(Mailing $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; $head[$h][1] = $langs->trans("MailRecipients"); - if ($object->nbemail > 0) $head[$h][1].= ''.$object->nbemail.''; + if ($object->nbemail > 0) $head[$h][1] .= ''.$object->nbemail.''; $head[$h][2] = 'targets'; $h++; } - if ( empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) + if (empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php index 7c329940b2d..fc1ca494d36 100644 --- a/htdocs/core/lib/expedition.lib.php +++ b/htdocs/core/lib/expedition.lib.php @@ -35,7 +35,7 @@ function expedition_prepare_head(Expedition $object) { global $langs, $conf, $user; - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); + if (!empty($conf->expedition->enabled)) $langs->load("sendings"); $langs->load("orders"); $h = 0; @@ -48,10 +48,10 @@ function expedition_prepare_head(Expedition $object) $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; $head[$h][1] = $langs->trans("Shipment"); - $hselected=$h; + $hselected = $h; $h++; - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; $head[$h][1] = $langs->trans("Receivings"); @@ -83,7 +83,7 @@ function expedition_admin_prepare_head() $h++; - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; $head[$h][1] = $langs->trans("Shipment"); @@ -92,7 +92,7 @@ function expedition_admin_prepare_head() } - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -100,7 +100,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) + if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); @@ -108,7 +108,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; $head[$h][1] = $langs->trans("Receivings"); @@ -116,7 +116,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT.'/admin/livraison_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -124,7 +124,7 @@ function expedition_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) + if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) { $head[$h][0] = DOL_URL_ROOT.'/admin/livraisondet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php index caef261b277..2767af2e792 100644 --- a/htdocs/core/lib/expensereport.lib.php +++ b/htdocs/core/lib/expensereport.lib.php @@ -34,7 +34,7 @@ function expensereport_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -47,28 +47,28 @@ function expensereport_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index d707063bbe8..8d0809f9768 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -51,7 +51,7 @@ function fichinter_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('InterventionContact'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -68,7 +68,7 @@ function fichinter_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; $objectres = new Dolresource($db); $linked_resources = $objectres->getElementResources('fichinter', $object->id); - $nbResource = (is_array($linked_resources)?count($linked_resources):0); + $nbResource = (is_array($linked_resources) ?count($linked_resources) : 0); // if (is_array($objectres->available_resources)) // { // foreach ($objectres->available_resources as $modresources => $resources) @@ -83,7 +83,7 @@ function fichinter_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); - if ($nbResource > 0) $head[$h][1].= ''.$nbResource.''; + if ($nbResource > 0) $head[$h][1] .= ''.$nbResource.''; $head[$h][2] = 'resource'; $h++; } @@ -91,23 +91,23 @@ function fichinter_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->ficheinter->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php index 14a23cc22c2..f54772c2339 100644 --- a/htdocs/core/lib/fiscalyear.lib.php +++ b/htdocs/core/lib/fiscalyear.lib.php @@ -34,7 +34,7 @@ function fiscalyear_prepare_head(Fiscalyear $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -45,7 +45,7 @@ function fiscalyear_prepare_head(Fiscalyear $object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear'); - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/format_cards.lib.php b/htdocs/core/lib/format_cards.lib.php index 7135082fac9..c46cd150a51 100644 --- a/htdocs/core/lib/format_cards.lib.php +++ b/htdocs/core/lib/format_cards.lib.php @@ -38,22 +38,22 @@ if ($resql) { while ($row = $db->fetch_array($resql)) { - $_Avery_Labels[$row['code']]['name']=$row['name']; - $_Avery_Labels[$row['code']]['paper-size']=$row['paper_size']; - $_Avery_Labels[$row['code']]['orientation']=$row['orientation']; - $_Avery_Labels[$row['code']]['metric']=$row['metric']; - $_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin']; - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; - $_Avery_Labels[$row['code']]['NX']=$row['nx']; - $_Avery_Labels[$row['code']]['NY']=$row['ny']; - $_Avery_Labels[$row['code']]['SpaceX']=$row['spacex']; - $_Avery_Labels[$row['code']]['SpaceY']=$row['spacey']; - $_Avery_Labels[$row['code']]['width']=$row['width']; - $_Avery_Labels[$row['code']]['height']=$row['height']; - $_Avery_Labels[$row['code']]['font-size']=$row['font_size']; - $_Avery_Labels[$row['code']]['custom_x']=$row['custom_x']; - $_Avery_Labels[$row['code']]['custom_y']=$row['custom_y']; + $_Avery_Labels[$row['code']]['name'] = $row['name']; + $_Avery_Labels[$row['code']]['paper-size'] = $row['paper_size']; + $_Avery_Labels[$row['code']]['orientation'] = $row['orientation']; + $_Avery_Labels[$row['code']]['metric'] = $row['metric']; + $_Avery_Labels[$row['code']]['marginLeft'] = $row['leftmargin']; + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; + $_Avery_Labels[$row['code']]['NX'] = $row['nx']; + $_Avery_Labels[$row['code']]['NY'] = $row['ny']; + $_Avery_Labels[$row['code']]['SpaceX'] = $row['spacex']; + $_Avery_Labels[$row['code']]['SpaceY'] = $row['spacey']; + $_Avery_Labels[$row['code']]['width'] = $row['width']; + $_Avery_Labels[$row['code']]['height'] = $row['height']; + $_Avery_Labels[$row['code']]['font-size'] = $row['font_size']; + $_Avery_Labels[$row['code']]['custom_x'] = $row['custom_x']; + $_Avery_Labels[$row['code']]['custom_y'] = $row['custom_y']; } } else @@ -62,7 +62,7 @@ else } // We add characteristics to the name -foreach($_Avery_Labels as $key => $val) +foreach ($_Avery_Labels as $key => $val) { - $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; + $_Avery_Labels[$key]['name'] .= ' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; } diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 9336d9b221f..3b41f2620b4 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -48,7 +48,7 @@ function facturefourn_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -62,11 +62,11 @@ function facturefourn_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } @@ -75,10 +75,10 @@ function facturefourn_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -116,12 +116,12 @@ function ordersupplier_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } - if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) + if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; @@ -139,32 +139,32 @@ function ordersupplier_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 34034abb280..2dc159170a7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1660,7 +1660,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlref .= '
'; } } - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID == '1' || preg_match('/'.preg_quote($object->element, '/').'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && ! empty($object->id)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID == '1' || preg_match('/'.preg_quote($object->element, '/').'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) { $morehtmlref .= '
'; $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id; @@ -3222,7 +3222,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_off', 'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected' ); - if (! isset($arrayconvpictotomarginleftonly[$pictowithouttext])) { + if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) { $marginleftonlyshort = 0; } @@ -3238,7 +3238,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'title_agenda'=>'bg-infoxbox-action', 'list-alt'=>'imgforviewmode', 'calendar'=>'imgforviewmode', 'calendarweek'=>'imgforviewmode', 'calendarmonth'=>'imgforviewmode', 'calendarday'=>'imgforviewmode', 'calendarperuser'=>'imgforviewmode' ); - if (! empty($arrayconvpictotomorcess[$pictowithouttext])) { + if (!empty($arrayconvpictotomorcess[$pictowithouttext])) { $morecss .= ($morecss ? ' ' : '').$arrayconvpictotomorcess[$pictowithouttext]; } @@ -5649,7 +5649,7 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1) $allowed_tags_string = '<'.$allowed_tags_string.'>'; if ($cleanalsosomestyles) { - $stringtoclean = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $stringtoclean); // Note: If hacker try to introduce css comment into string to bypass this regex, the string must also be encoded by the dol_htmlentitiesbr during output so it become harmless + $stringtoclean = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $stringtoclean); // Note: If hacker try to introduce css comment into string to bypass this regex, the string must also be encoded by the dol_htmlentitiesbr during output so it become harmless } $temp = strip_tags($stringtoclean, $allowed_tags_string); diff --git a/htdocs/core/lib/functions_ch.lib.php b/htdocs/core/lib/functions_ch.lib.php index 353c8d0a2ac..04e74837853 100644 --- a/htdocs/core/lib/functions_ch.lib.php +++ b/htdocs/core/lib/functions_ch.lib.php @@ -32,139 +32,139 @@ function dol_ch_controle_bvrb($bvrb) { // Init array for control - $tableau[0][0]=0; - $tableau[0][1]=9; - $tableau[0][2]=4; - $tableau[0][3]=6; - $tableau[0][4]=8; - $tableau[0][5]=2; - $tableau[0][6]=7; - $tableau[0][7]=1; - $tableau[0][8]=3; - $tableau[0][9]=5; - $tableau[0][10]=0; + $tableau[0][0] = 0; + $tableau[0][1] = 9; + $tableau[0][2] = 4; + $tableau[0][3] = 6; + $tableau[0][4] = 8; + $tableau[0][5] = 2; + $tableau[0][6] = 7; + $tableau[0][7] = 1; + $tableau[0][8] = 3; + $tableau[0][9] = 5; + $tableau[0][10] = 0; - $tableau[1][0]=9; - $tableau[1][1]=4; - $tableau[1][2]=6; - $tableau[1][3]=8; - $tableau[1][4]=2; - $tableau[1][5]=7; - $tableau[1][6]=1; - $tableau[1][7]=3; - $tableau[1][8]=5; - $tableau[1][9]=0; - $tableau[1][10]=9; + $tableau[1][0] = 9; + $tableau[1][1] = 4; + $tableau[1][2] = 6; + $tableau[1][3] = 8; + $tableau[1][4] = 2; + $tableau[1][5] = 7; + $tableau[1][6] = 1; + $tableau[1][7] = 3; + $tableau[1][8] = 5; + $tableau[1][9] = 0; + $tableau[1][10] = 9; - $tableau[2][0]=4; - $tableau[2][1]=6; - $tableau[2][2]=8; - $tableau[2][3]=2; - $tableau[2][4]=7; - $tableau[2][5]=1; - $tableau[2][6]=3; - $tableau[2][7]=5; - $tableau[2][8]=0; - $tableau[2][9]=9; - $tableau[2][10]=8; + $tableau[2][0] = 4; + $tableau[2][1] = 6; + $tableau[2][2] = 8; + $tableau[2][3] = 2; + $tableau[2][4] = 7; + $tableau[2][5] = 1; + $tableau[2][6] = 3; + $tableau[2][7] = 5; + $tableau[2][8] = 0; + $tableau[2][9] = 9; + $tableau[2][10] = 8; - $tableau[3][0]=6; - $tableau[3][1]=8; - $tableau[3][2]=2; - $tableau[3][3]=7; - $tableau[3][4]=1; - $tableau[3][5]=3; - $tableau[3][6]=5; - $tableau[3][7]=0; - $tableau[3][8]=9; - $tableau[3][9]=4; - $tableau[3][10]=7; + $tableau[3][0] = 6; + $tableau[3][1] = 8; + $tableau[3][2] = 2; + $tableau[3][3] = 7; + $tableau[3][4] = 1; + $tableau[3][5] = 3; + $tableau[3][6] = 5; + $tableau[3][7] = 0; + $tableau[3][8] = 9; + $tableau[3][9] = 4; + $tableau[3][10] = 7; - $tableau[4][0]=8; - $tableau[4][1]=2; - $tableau[4][2]=7; - $tableau[4][3]=1; - $tableau[4][4]=3; - $tableau[4][5]=5; - $tableau[4][6]=0; - $tableau[4][7]=9; - $tableau[4][8]=4; - $tableau[4][9]=6; - $tableau[4][10]=6; + $tableau[4][0] = 8; + $tableau[4][1] = 2; + $tableau[4][2] = 7; + $tableau[4][3] = 1; + $tableau[4][4] = 3; + $tableau[4][5] = 5; + $tableau[4][6] = 0; + $tableau[4][7] = 9; + $tableau[4][8] = 4; + $tableau[4][9] = 6; + $tableau[4][10] = 6; - $tableau[5][0]=2; - $tableau[5][1]=7; - $tableau[5][2]=1; - $tableau[5][3]=3; - $tableau[5][4]=5; - $tableau[5][5]=0; - $tableau[5][6]=9; - $tableau[5][7]=4; - $tableau[5][8]=6; - $tableau[5][9]=8; - $tableau[5][10]=5; + $tableau[5][0] = 2; + $tableau[5][1] = 7; + $tableau[5][2] = 1; + $tableau[5][3] = 3; + $tableau[5][4] = 5; + $tableau[5][5] = 0; + $tableau[5][6] = 9; + $tableau[5][7] = 4; + $tableau[5][8] = 6; + $tableau[5][9] = 8; + $tableau[5][10] = 5; - $tableau[6][0]=7; - $tableau[6][1]=1; - $tableau[6][2]=3; - $tableau[6][3]=5; - $tableau[6][4]=0; - $tableau[6][5]=9; - $tableau[6][6]=4; - $tableau[6][7]=6; - $tableau[6][8]=8; - $tableau[6][9]=2; - $tableau[6][10]=4; + $tableau[6][0] = 7; + $tableau[6][1] = 1; + $tableau[6][2] = 3; + $tableau[6][3] = 5; + $tableau[6][4] = 0; + $tableau[6][5] = 9; + $tableau[6][6] = 4; + $tableau[6][7] = 6; + $tableau[6][8] = 8; + $tableau[6][9] = 2; + $tableau[6][10] = 4; - $tableau[7][0]=1; - $tableau[7][1]=3; - $tableau[7][2]=5; - $tableau[7][3]=0; - $tableau[7][4]=9; - $tableau[7][5]=4; - $tableau[7][6]=6; - $tableau[7][7]=8; - $tableau[7][8]=2; - $tableau[7][9]=7; - $tableau[7][10]=3; + $tableau[7][0] = 1; + $tableau[7][1] = 3; + $tableau[7][2] = 5; + $tableau[7][3] = 0; + $tableau[7][4] = 9; + $tableau[7][5] = 4; + $tableau[7][6] = 6; + $tableau[7][7] = 8; + $tableau[7][8] = 2; + $tableau[7][9] = 7; + $tableau[7][10] = 3; - $tableau[8][0]=3; - $tableau[8][1]=5; - $tableau[8][2]=0; - $tableau[8][3]=9; - $tableau[8][4]=4; - $tableau[8][5]=6; - $tableau[8][6]=8; - $tableau[8][7]=2; - $tableau[8][8]=7; - $tableau[8][9]=1; - $tableau[8][10]=2; + $tableau[8][0] = 3; + $tableau[8][1] = 5; + $tableau[8][2] = 0; + $tableau[8][3] = 9; + $tableau[8][4] = 4; + $tableau[8][5] = 6; + $tableau[8][6] = 8; + $tableau[8][7] = 2; + $tableau[8][8] = 7; + $tableau[8][9] = 1; + $tableau[8][10] = 2; - $tableau[9][0]=5; - $tableau[9][1]=0; - $tableau[9][2]=9; - $tableau[9][3]=4; - $tableau[9][4]=6; - $tableau[9][5]=8; - $tableau[9][6]=2; - $tableau[9][7]=7; - $tableau[9][8]=1; - $tableau[9][9]=3; - $tableau[9][10]=1; + $tableau[9][0] = 5; + $tableau[9][1] = 0; + $tableau[9][2] = 9; + $tableau[9][3] = 4; + $tableau[9][4] = 6; + $tableau[9][5] = 8; + $tableau[9][6] = 2; + $tableau[9][7] = 7; + $tableau[9][8] = 1; + $tableau[9][9] = 3; + $tableau[9][10] = 1; // Clean data - $bv=str_replace(' ', '', $bvrb); + $bv = str_replace(' ', '', $bvrb); // Make control - $report=0; - while (dol_strlen($bv)>1) + $report = 0; + while (dol_strlen($bv) > 1) { - $match=substr($bv, 0, 1); - $report=$tableau[$report][$match]; - $bv=substr($bv, 1); + $match = substr($bv, 0, 1); + $report = $tableau[$report][$match]; + $bv = substr($bv, 1); } - $controle=$tableau[$report][10]; + $controle = $tableau[$report][10]; - return ($controle==$bv); + return ($controle == $bv); } diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index ac5cfab832f..ae0eb86882e 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -35,11 +35,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = { //declaring of global variables global $conf; - $USE_PROXY=empty($conf->global->MAIN_PROXY_USE)?0:$conf->global->MAIN_PROXY_USE; - $PROXY_HOST=empty($conf->global->MAIN_PROXY_HOST)?0:$conf->global->MAIN_PROXY_HOST; - $PROXY_PORT=empty($conf->global->MAIN_PROXY_PORT)?0:$conf->global->MAIN_PROXY_PORT; - $PROXY_USER=empty($conf->global->MAIN_PROXY_USER)?0:$conf->global->MAIN_PROXY_USER; - $PROXY_PASS=empty($conf->global->MAIN_PROXY_PASS)?0:$conf->global->MAIN_PROXY_PASS; + $USE_PROXY = empty($conf->global->MAIN_PROXY_USE) ? 0 : $conf->global->MAIN_PROXY_USE; + $PROXY_HOST = empty($conf->global->MAIN_PROXY_HOST) ? 0 : $conf->global->MAIN_PROXY_HOST; + $PROXY_PORT = empty($conf->global->MAIN_PROXY_PORT) ? 0 : $conf->global->MAIN_PROXY_PORT; + $PROXY_USER = empty($conf->global->MAIN_PROXY_USER) ? 0 : $conf->global->MAIN_PROXY_USER; + $PROXY_PASS = empty($conf->global->MAIN_PROXY_PASS) ? 0 : $conf->global->MAIN_PROXY_PASS; dol_syslog("getURLContent postorget=".$postorget." URL=".$url." param=".$param); @@ -54,51 +54,51 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function'); - @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation ?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); - curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it + curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it // By default use tls decied by PHP. // You can force, if supported a version like TLSv1 or TLSv1.2 - if (! empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); + if (!empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); //curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2 //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // PHP 5.5 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response if ($postorget == 'POST') { - curl_setopt($ch, CURLOPT_POST, 1); // POST - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields + curl_setopt($ch, CURLOPT_POST, 1); // POST + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields } elseif ($postorget == 'POSTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string } elseif ($postorget == 'PUT') { - $array_param=null; + $array_param = null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' - if (! is_array($param)) parse_str($param, $array_param); + if (!is_array($param)) parse_str($param, $array_param); else { dol_syslog("parameter param must be a string", LOG_WARNING); - $array_param=$param; + $array_param = $param; } - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields } elseif ($postorget == 'PUTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' - curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string + curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string } elseif ($postorget == 'HEAD') { @@ -107,40 +107,40 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } elseif ($postorget == 'DELETE') { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST } else { - curl_setopt($ch, CURLOPT_POST, 0); // GET + curl_setopt($ch, CURLOPT_POST, 0); // GET } //if USE_PROXY constant set at begin of this method. if ($USE_PROXY) { - dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); + dol_syslog("getURLContent set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 - curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); - if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); + if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); } //getting response from server $response = curl_exec($ch); - $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request + $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request dol_syslog("getURLContent request=".$request); //dol_syslog("getURLContent response =".response); // This may contains binary data, so we dont output it - dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it + dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it - $rep=array(); + $rep = array(); if (curl_errno($ch)) { // Ad keys to $rep - $rep['content']=$response; + $rep['content'] = $response; // moving to display page to display curl errors - $rep['curl_error_no']=curl_errno($ch); - $rep['curl_error_msg']=curl_error($ch); + $rep['curl_error_no'] = curl_errno($ch); + $rep['curl_error_msg'] = curl_error($ch); dol_syslog("getURLContent response array is ".join(',', $rep)); } @@ -155,9 +155,9 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent http_code=".$rep['http_code']); // Add more keys to $rep - $rep['content']=$response; - $rep['curl_error_no']=''; - $rep['curl_error_msg']=''; + $rep['content'] = $response; + $rep['curl_error_no'] = ''; + $rep['curl_error_msg'] = ''; //closing the curl curl_close($ch); @@ -177,19 +177,19 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = */ function getDomainFromURL($url, $mode = 0) { - $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// - $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain + $tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s):// + $tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain if ($mode == 2) { - $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' + $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com' } else { - $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' + $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com' } if (empty($mode)) { - $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) + $tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...) } return $tmpdomain; @@ -205,12 +205,12 @@ function getDomainFromURL($url, $mode = 0) */ function getRootURLFromURL($url) { - $prefix=''; + $prefix = ''; $tmpurl = $url; $reg = null; if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1]; - $tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s):// - $tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain + $tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s):// + $tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain return $prefix.$tmpurl; } diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index f1b18df11b2..987895c27d8 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -44,10 +44,10 @@ function holiday_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index b61fba236e2..83eafa2548f 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -36,7 +36,7 @@ function establishment_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -47,7 +47,7 @@ function establishment_prepare_head($object) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment'); - $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 1e6ebfa6d85..a8469d6bb8b 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -328,7 +328,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) $infoImg = getimagesize($fileSource); // Get image infos $orientation = $exif['Orientation']; - if($orientation != 1){ + if ($orientation != 1) { $img = imagecreatefromjpeg($fileSource); $deg = 0; switch ($orientation) { @@ -413,42 +413,42 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - global $conf,$langs; + global $conf, $langs; dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); // Clean parameters - $file=trim($file); + $file = trim($file); // Check parameters - if (! $file) + if (!$file) { // Si le fichier n'a pas ete indique return 'ErrorBadParameters'; } - elseif (! file_exists($file)) + elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); return $langs->trans("ErrorFileNotFound", $file); } - elseif(image_format_supported($file) < 0) + elseif (image_format_supported($file) < 0) { dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); return 'ErrorBadImageFormat'; } - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { + elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); return 'Error: Wrong value for parameter maxWidth'; } - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { + elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); return 'Error: Wrong value for parameter maxHeight'; } - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $imgWidth = $infoImg[0]; // Largeur de l'image @@ -462,8 +462,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged + if ($maxWidth == -1) $maxWidth = $infoImg[0]; // If size is -1, we keep unchanged + if ($maxHeight == -1) $maxHeight = $infoImg[1]; // If size is -1, we keep unchanged // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) @@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; } - if (! is_resource($img)) + if (!is_resource($img)) { dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; @@ -539,7 +539,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $exifAngle = false; if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { - switch($ort) + switch ($ort) { case 3: // 180 rotate left $exifAngle = 180; @@ -563,7 +563,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', { $rotated = false; - if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case { imagealphablending($img, false); imagesavealpha($img, true); diff --git a/htdocs/core/lib/import.lib.php b/htdocs/core/lib/import.lib.php index 32f9d0d87d2..8fa6a995331 100644 --- a/htdocs/core/lib/import.lib.php +++ b/htdocs/core/lib/import.lib.php @@ -36,12 +36,12 @@ function import_prepare_head($param, $maxstep = 0) { global $langs; - if (empty($maxstep)) $maxstep=6; + if (empty($maxstep)) $maxstep = 6; - $h=0; + $h = 0; $head = array(); - $i=1; - while($i <= $maxstep) + $i = 1; + while ($i <= $maxstep) { $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step='.$i.$param; $head[$h][1] = $langs->trans("Step")." ".$i; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 15de60eb791..703d50c97f8 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -50,28 +50,28 @@ function facture_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } //if ($fac->mode_reglement_code == 'PRE') - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { - $nbStandingOrders=0; + $nbStandingOrders = 0; $sql = "SELECT COUNT(pfd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE pfd.fk_facture = ".$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($obj) $nbStandingOrders = $obj->nb; } else dol_print_error($db); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id; $head[$h][1] = $langs->trans('StandingOrders'); - if ($nbStandingOrders > 0) $head[$h][1].= ''.$nbStandingOrders.''; + if ($nbStandingOrders > 0) $head[$h][1] .= ''.$nbStandingOrders.''; $head[$h][2] = 'standingorders'; $h++; } @@ -85,23 +85,23 @@ function facture_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index 6e79021e17b..d5ca3431845 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -50,83 +50,83 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf') { $sql = "SELECT DISTINCT f.rowid, f.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlwhere=''; - $sqlorder=''; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlwhere = ''; + $sqlorder = ''; if (in_array('all', $filter)) { $sqlorder = " ORDER BY f.ref ASC"; } if (in_array('date', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.datef >= '".$db->idate($dateafterdate)."'"; - $sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND f.datef >= '".$db->idate($dateafterdate)."'"; + $sqlwhere .= " AND f.datef <= '".$db->idate($datebeforedate)."'"; $sqlorder = " ORDER BY f.datef ASC"; } if (in_array('nopayment', $filter)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND pf.fk_paiement IS NULL"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND pf.fk_paiement IS NULL"; } if (in_array('payments', $filter) || in_array('bank', $filter)) { - $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; - if (in_array('bank', $filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.rowid = pf.fk_facture"; - $sqlwhere.= " AND pf.fk_paiement = p.rowid"; + $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; + if (in_array('bank', $filter)) $sql .= ", ".MAIN_DB_PREFIX."bank as b"; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= " f.fk_statut > 0"; + $sqlwhere .= " AND f.rowid = pf.fk_facture"; + $sqlwhere .= " AND pf.fk_paiement = p.rowid"; if (in_array('payments', $filter)) { - $sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; - $sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; + $sqlwhere .= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; + $sqlwhere .= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; } if (in_array('bank', $filter)) { - $sqlwhere.= " AND p.fk_bank = b.rowid"; - $sqlwhere.= " AND b.fk_account = ".$paymentbankid; + $sqlwhere .= " AND p.fk_bank = b.rowid"; + $sqlwhere .= " AND b.fk_account = ".$paymentbankid; } $sqlorder = " ORDER BY p.datep ASC"; } if (in_array('nodeposit', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 3'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 3'; } if (in_array('noreplacement', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 1'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 1'; } if (in_array('nocreditnote', $filter)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 2'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' type <> 2'; } if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')'; } if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) { - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' f.fk_soc IN ('.join(',', $thirdpartiesid).')'; + if (empty($sqlwhere)) $sqlwhere = ' WHERE '; + else $sqlwhere .= " AND"; + $sqlwhere .= ' f.fk_soc IN ('.join(',', $thirdpartiesid).')'; } - if ($sqlwhere) $sql.=$sqlwhere; - if ($sqlorder) $sql.=$sqlorder; + if ($sqlwhere) $sql .= $sqlwhere; + if ($sqlorder) $sql .= $sqlorder; //print $sql; exit; dol_syslog("scripts/invoices/rebuild_merge.php:", LOG_DEBUG); @@ -138,10 +138,10 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $error = 0; $result = 0; - $files = array() ; // liste les fichiers + $files = array(); // liste les fichiers dol_syslog("scripts/invoices/rebuild_merge.php", LOG_DEBUG); - if ( $resql=$db->query($sql) ) + if ($resql = $db->query($sql)) { $num = $db->num_rows($resql); $cpt = 0; @@ -159,11 +159,11 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $obj = $db->fetch_object($resql); $fac = new Facture($db); - $result=$fac->fetch($obj->rowid); + $result = $fac->fetch($obj->rowid); if ($result > 0) { $outputlangs = $langs; - if (! empty($newlangid)) + if (!empty($newlangid)) { if ($outputlangs->defaultlang != $newlangid) { @@ -171,11 +171,11 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte $outputlangs->setDefaultLang($newlangid); } } - $filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; - if ($regenerate || ! dol_is_file($filename)) + $filename = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; + if ($regenerate || !dol_is_file($filename)) { if ($usestdout) print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n"; - $result= $fac->generateDocument($regenerate?$regenerate:$fac->modelpdf, $outputlangs); + $result = $fac->generateDocument($regenerate ? $regenerate : $fac->modelpdf, $outputlangs); } else { if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n"; @@ -188,8 +188,8 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte if ($result <= 0) { $error++; - if ($usestdout) print "Error: Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid)."\n"; - else dol_syslog("Failed to build PDF for invoice ".($fac->ref?$fac->ref:' id '.$obj->rowid), LOG_ERR); + if ($usestdout) print "Error: Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n"; + else dol_syslog("Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR); } $cpt++; @@ -197,10 +197,10 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Define format of output PDF - $formatarray=pdf_getFormat($langs); + $formatarray = pdf_getFormat($langs); $page_largeur = $formatarray['width']; $page_hauteur = $formatarray['height']; - $format = array($page_largeur,$page_hauteur); + $format = array($page_largeur, $page_hauteur); if ($usestdout) print "Using output PDF format ".join('x', $format)."\n"; else dol_syslog("Using output PDF format ".join('x', $format), LOG_ERR); @@ -210,7 +210,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte //--------------------------------------------------------- // Create empty PDF - $pdf=pdf_getInstance($format); + $pdf = pdf_getInstance($format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -222,7 +222,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte //$pdf->SetCompression(false); // Add all others - foreach($files as $file) + foreach ($files as $file) { if ($usestdout) print "Merge PDF file for invoice ".$file."\n"; else dol_syslog("Merge PDF file for invoice ".$file); @@ -242,21 +242,21 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte dol_mkdir($diroutputpdf); // Save merged file - $filename=$fileprefix; - if (empty($filename)) $filename='mergedpdf'; - if (! empty($filesuffix)) $filename.='_'.$filesuffix; - $file=$diroutputpdf.'/'.$filename.'.pdf'; + $filename = $fileprefix; + if (empty($filename)) $filename = 'mergedpdf'; + if (!empty($filesuffix)) $filename .= '_'.$filesuffix; + $file = $diroutputpdf.'/'.$filename.'.pdf'; - if (! $error && $pagecount) + if (!$error && $pagecount) { $pdf->Output($file, 'F'); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); } if ($usestdout) { - if (! $error) print "Merged PDF has been built in ".$file."\n"; + if (!$error) print "Merged PDF has been built in ".$file."\n"; else print "Can't build PDF ".$file."\n"; } diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 77b856e2d8e..44ad9cc6ff1 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -23,7 +23,7 @@ * \ingroup core */ -if (! function_exists('json_encode')) +if (!function_exists('json_encode')) { /** * Implement json_encode for PHP that does not have module enabled. @@ -49,14 +49,14 @@ function dol_json_encode($elements) { dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); - $num=0; + $num = 0; if (is_object($elements)) // Count number of properties for an object { - foreach($elements as $key => $value) $num++; + foreach ($elements as $key => $value) $num++; } else { - $num=count($elements); + $num = count($elements); } //var_dump($num); @@ -64,16 +64,16 @@ function dol_json_encode($elements) if (is_numeric(key($elements)) && key($elements) == 0) { // indexed (list) - $keysofelements=array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. + $keysofelements = array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. $output = '['; for ($i = 0, $last = ($num - 1); $i < $num; $i++) { - if (! isset($elements[$keysofelements[$i]])) continue; - if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]); + if (!isset($elements[$keysofelements[$i]])) continue; + if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output .= json_encode($elements[$keysofelements[$i]]); else $output .= _val($elements[$keysofelements[$i]]); - if ($i !== $last) $output.= ','; + if ($i !== $last) $output .= ','; } - $output.= ']'; + $output .= ']'; } else { @@ -81,18 +81,18 @@ function dol_json_encode($elements) $output = '{'; $last = $num - 1; $i = 0; - $tmpelements=array(); - if (is_array($elements)) $tmpelements=$elements; - if (is_object($elements)) $tmpelements=get_object_vars($elements); - foreach($tmpelements as $key => $value) + $tmpelements = array(); + if (is_array($elements)) $tmpelements = $elements; + if (is_object($elements)) $tmpelements = get_object_vars($elements); + foreach ($tmpelements as $key => $value) { $output .= '"'.$key.'":'; - if (is_array($value)) $output.= json_encode($value); + if (is_array($value)) $output .= json_encode($value); else $output .= _val($value); - if ($i !== $last) $output.= ','; + if ($i !== $last) $output .= ','; ++$i; } - $output.= '}'; + $output .= '}'; } // return @@ -204,7 +204,7 @@ function _val($val) else return 'null'; } -if (! function_exists('json_decode')) +if (!function_exists('json_decode')) { /** * Implement json_decode for PHP that does not support it @@ -234,34 +234,34 @@ function dol_json_decode($json, $assoc = false) $comment = false; - $out=''; - $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length - for ($i=0; $i<$strLength; $i++) + $out = ''; + $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length + for ($i = 0; $i < $strLength; $i++) { - if (! $comment) + if (!$comment) { - if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; - elseif (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; - elseif ($json[$i] == ':') $out.= ' => '; - else $out.=$json[$i]; + if (($json[$i] == '{') || ($json[$i] == '[')) $out .= 'array('; + elseif (($json[$i] == '}') || ($json[$i] == ']')) $out .= ')'; + elseif ($json[$i] == ':') $out .= ' => '; + else $out .= $json[$i]; } - else $out.= $json[$i]; - if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; + else $out .= $json[$i]; + if ($json[$i] == '"' && $json[($i - 1)] != "\\") $comment = !$comment; } - $out=_unval($out); + $out = _unval($out); // Return an array if ($out != '') eval('$array = '.$out.';'); - else $array=array(); + else $array = array(); // Return an object - if (! $assoc) + if (!$assoc) { - if (! empty($array)) + if (!empty($array)) { $object = false; - if (count($array)>0) { + if (count($array) > 0) { $object = (object) array(); } foreach ($array as $key => $value) @@ -290,9 +290,9 @@ function _unval($val) while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) { // single, escaped unicode character - $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); + $utf16 = chr(hexdec($reg[1])).chr(hexdec($reg[2])); $utf8 = utf162utf8($utf16); - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); + $val = preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); } return $val; } @@ -316,7 +316,7 @@ function utf162utf8($utf16) $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); - switch(true) { + switch (true) { case ((0x7F & $bytes) == $bytes): // this case should never be reached, because we are in ASCII range // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 @@ -357,7 +357,7 @@ function utf82utf16($utf8) return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); } - switch(strlen($utf8)) { + switch (strlen($utf8)) { case 1: // this case should never be reached, because we are in ASCII range // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 @@ -366,12 +366,12 @@ function utf82utf16($utf8) case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); + return chr(0x07 & (ord($utf8[0]) >> 2)).chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); + return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))).chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); } // ignoring UTF-32 for now, sorry diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index e751dfd68c8..a3c352a0405 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -54,21 +54,21 @@ function loan_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->loan->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; $head[$tab][1] = $langs->trans("Notes"); - if($nbNote > 0) $head[$tab][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$tab][1] .= ''.$nbNote.''; $head[$tab][2] = 'note'; $tab++; } diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 1f643dd8a48..d6993845488 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -42,8 +42,8 @@ function member_prepare_head(Adherent $object) $head[$h][2] = 'general'; $h++; - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); @@ -53,13 +53,13 @@ function member_prepare_head(Adherent $object) $h++; } - if (! empty($user->rights->adherent->cotisation->lire)) + if (!empty($user->rights->adherent->cotisation->lire)) { - $nbSubscription = is_array($object->subscriptions)?count($object->subscriptions):0; + $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0; $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; - if ($nbSubscription > 0) $head[$h][1].= ''.$nbSubscription.''; + if ($nbSubscription > 0) $head[$h][1] .= ''.$nbSubscription.''; $h++; } @@ -70,13 +70,13 @@ function member_prepare_head(Adherent $object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); $nbNote = 0; - if(!empty($object->note)) $nbNote++; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $h++; // Attachments @@ -84,22 +84,22 @@ function member_prepare_head(Adherent $object) require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member'); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; // Show agenda tab - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -120,7 +120,7 @@ function member_type_prepare_head(AdherentType $object) { global $langs, $conf, $user; - $h=0; + $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id; @@ -129,7 +129,7 @@ function member_type_prepare_head(AdherentType $object) $h++; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id; $head[$h][1] = $langs->trans("Translation"); @@ -137,8 +137,8 @@ function member_type_prepare_head(AdherentType $object) $h++; } - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 22e660b2e22..ba1ed6bb8a0 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -21,14 +21,14 @@ * \brief Set of function for memory/cache management */ -global $shmkeys,$shmoffset; +global $shmkeys, $shmoffset; -$shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6, - 'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12, - 'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19, - 'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24, - 'donations'=>25,'contracts'=>26); -$shmoffset=1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. +$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6, + 'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12, + 'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19, + 'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24, + 'donations'=>25, 'contracts'=>26); +$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. @@ -95,7 +95,7 @@ function dol_setcache($memoryid, $data) // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $result=dol_setshmop($memoryid, $data); + $result = dol_setshmop($memoryid, $data); } return $result; @@ -167,7 +167,7 @@ function dol_getcache($memoryid) // Using shmop elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $data=dol_getshmop($memoryid); + $data = dol_getshmop($memoryid); return $data; } @@ -184,9 +184,9 @@ function dol_getcache($memoryid) */ function dol_getshmopaddress($memoryid) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; if (empty($shmkeys[$memoryid])) return 0; - return $shmkeys[$memoryid]+$shmoffset; + return $shmkeys[$memoryid] + $shmoffset; } /** @@ -196,13 +196,13 @@ function dol_getshmopaddress($memoryid) */ function dol_listshmop() { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; - $resarray=array(); - foreach($shmkeys as $key => $val) + $resarray = array(); + foreach ($shmkeys as $key => $val) { - $result=dol_getshmop($key); - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; + $result = dol_getshmop($key); + if (!is_numeric($result) || $result > 0) $resarray[$key] = $result; } return $resarray; } @@ -216,25 +216,25 @@ function dol_listshmop() */ function dol_setshmop($memoryid, $data) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; //print 'dol_setshmop memoryid='.$memoryid."
\n"; - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; - $shmkey=dol_getshmopaddress($memoryid); - $newdata=serialize($data); - $size=strlen($newdata); + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0; + $shmkey = dol_getshmopaddress($memoryid); + $newdata = serialize($data); + $size = strlen($newdata); //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes
\n"; - $handle=shmop_open($shmkey, 'c', 0644, 6+$size); + $handle = shmop_open($shmkey, 'c', 0644, 6 + $size); if ($handle) { - $shm_bytes_written1=shmop_write($handle, str_pad($size, 6), 0); - $shm_bytes_written2=shmop_write($handle, $newdata, 6); - if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) + $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0); + $shm_bytes_written2 = shmop_write($handle, $newdata, 6); + if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata))) { print "Couldn't write the entire length of data\n"; } shmop_close($handle); - return ($shm_bytes_written1+$shm_bytes_written2); + return ($shm_bytes_written1 + $shm_bytes_written2); } else { @@ -251,16 +251,16 @@ function dol_setshmop($memoryid, $data) */ function dol_getshmop($memoryid) { - global $shmkeys,$shmoffset; + global $shmkeys, $shmoffset; - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; - $shmkey=dol_getshmopaddress($memoryid); + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0; + $shmkey = dol_getshmopaddress($memoryid); //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."
\n"; - $handle=@shmop_open($shmkey, 'a', 0, 0); + $handle = @shmop_open($shmkey, 'a', 0, 0); if ($handle) { - $size=trim(shmop_read($handle, 0, 6)); - if ($size) $data=unserialize(shmop_read($handle, 6, $size)); + $size = trim(shmop_read($handle, 0, 6)); + if ($size) $data = unserialize(shmop_read($handle, 6, $size)); else return -1; shmop_close($handle); } diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php index f17d79c6207..85142e0e631 100644 --- a/htdocs/core/lib/multicurrency.lib.php +++ b/htdocs/core/lib/multicurrency.lib.php @@ -55,10 +55,10 @@ function multicurrencyLimitPrepareHead($aCurrencies) { global $langs; - $i=0; + $i = 0; $head = array(); - foreach($aCurrencies as $currency) + foreach ($aCurrencies as $currency) { $head[$i][0] = $_SERVER['PHP_SELF'].'?currencycode='.$currency; $head[$i][1] = $langs->trans("Currency".$currency).' ('.$langs->getCurrencySymbol($currency).')'; diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index eb1a5495a95..34e1d99bd80 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -24,20 +24,20 @@ // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) -$supportedoauth2array=array( +$supportedoauth2array = array( 'OAUTH_GOOGLE_NAME'=>'google', ); if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME']='stripetest'; - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME']='stripelive'; + $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = 'stripetest'; + $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = 'stripelive'; } -$supportedoauth2array['OAUTH_GITHUB_NAME']='github'; +$supportedoauth2array['OAUTH_GITHUB_NAME'] = 'github'; // API access parameters OAUTH -$list = array ( +$list = array( array( 'OAUTH_AMAZON_NAME', 'OAUTH_AMAZON_ID', diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 54d850d99b6..3d2847e926b 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -53,7 +53,7 @@ function commande_prepare_head(Commande $object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -61,16 +61,16 @@ function commande_prepare_head(Commande $object) if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) { - $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; + $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; - $text=''; - if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments"); - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; - if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings"); - if ($nbShipments > 0 || $nbReceiption > 0) $text.= ''.($nbShipments?$nbShipments:0); - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.='/'; - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0); - if ($nbShipments > 0 || $nbReceiption > 0) $text.= ''; + $text = ''; + if ($conf->expedition_bon->enabled) $text .= $langs->trans("Shipments"); + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= '/'; + if ($conf->livraison_bon->enabled) $text .= $langs->trans("Receivings"); + if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''.($nbShipments ? $nbShipments : 0); + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= '/'; + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0); + if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''; $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; @@ -85,23 +85,23 @@ function commande_prepare_head(Commande $object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/parsemd.lib.php b/htdocs/core/lib/parsemd.lib.php index 280e77dcc9c..7dfd025609c 100644 --- a/htdocs/core/lib/parsemd.lib.php +++ b/htdocs/core/lib/parsemd.lib.php @@ -33,7 +33,7 @@ function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null) { if (is_array($replaceimagepath)) { - foreach($replaceimagepath as $key => $val) + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; @@ -67,7 +67,7 @@ function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null { if (is_array($replaceimagepath)) { - foreach($replaceimagepath as $key => $val) + foreach ($replaceimagepath as $key => $val) { $keytoreplace = ']('.$key; $valafter = ']('.$val; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index e7a9bd51034..80aed36f674 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -99,22 +99,22 @@ function getValidOnlinePaymentMethods($paymentmethod = '') { global $conf, $langs; - $validpaymentmethod=array(); + $validpaymentmethod = array(); - if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { $langs->load("paypal"); - $validpaymentmethod['paypal']='valid'; + $validpaymentmethod['paypal'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { $langs->load("paybox"); - $validpaymentmethod['paybox']='valid'; + $validpaymentmethod['paybox'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) + if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) { $langs->load("stripe"); - $validpaymentmethod['stripe']='valid'; + $validpaymentmethod['stripe'] = 'valid'; } // TODO Add trigger @@ -173,107 +173,107 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag if ($type == 'free') { - $out=$urltouse.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + else $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } //if ($mode) $out.='&noidempotency=1'; } elseif ($type == 'order') { - $out=$urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); - if ($mode == 1) $out.='order_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'order_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'invoice') { - $out=$urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); - if ($mode == 1) $out.='invoice_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'invoice_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'contractline') { - $out=$urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); - if ($mode == 1) $out.='contractline_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'contractline_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } elseif ($type == 'member' || $type == 'membersubscription') { - $out=$urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); - if ($mode == 1) $out.='member_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'member_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'donation') { - $out=$urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); - if ($mode == 1) $out.='donation_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + $out = $urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'donation_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + donation_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } // For multicompany - if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities + if (!empty($out) && !empty($conf->multicompany->enabled)) $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities return $out; } diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index 035f0adb754..eca43aef3f6 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -78,8 +78,8 @@ function prelevement_prepare_head(BonPrelevement $object) function prelevement_check_config() { global $conf; - if(empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; - if(empty($conf->global->PRELEVEMENT_ICS)) return -1; - if(empty($conf->global->PRELEVEMENT_USER)) return -1; + if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1; + if (empty($conf->global->PRELEVEMENT_ICS)) return -1; + if (empty($conf->global->PRELEVEMENT_USER)) return -1; return 0; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9b9f000cf17..428d976ab6d 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -487,10 +487,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Ref of task - if (count($arrayfields)>0 && !empty($arrayfields['t.ref']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.ref']['checked'])) { print ''; if ($showlineingray) { - print '' . img_object('', 'projecttask') . ' ' . $lines[$i]->ref . ''; + print ''.img_object('', 'projecttask').' '.$lines[$i]->ref.''; } else { print $taskstatic->getNomUrl(1, 'withproject'); } @@ -498,7 +498,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Title of task - if (count($arrayfields)>0 && !empty($arrayfields['t.label']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) { print ""; if ($showlineingray) print ''; @@ -516,21 +516,21 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; } - if (count($arrayfields)>0 && !empty($arrayfields['t.description']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.description']['checked'])) { print ""; print $lines[$i]->description; print "\n"; } // Date start - if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) { print ''; print dol_print_date($lines[$i]->date_start, 'dayhour'); print ''; } // Date end - if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) { print ''; print dol_print_date($lines[$i]->date_end, 'dayhour'); if ($taskstatic->hasDelay()) @@ -544,7 +544,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) - if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) { print ''; $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks @@ -558,11 +558,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Time spent - if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; if ($showlineingray) print ''; - else print ''; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; @@ -573,18 +573,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Progress calculated (Note: ->duration is time spent) - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; if ($lines[$i]->planned_workload || $lines[$i]->duration) { if ($lines[$i]->planned_workload) - print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2) . ' %'; - else print '' . $langs->trans('WorkloadNotDefined') . ''; + print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; + else print ''.$langs->trans('WorkloadNotDefined').''; } print ''; } // Progress declared - if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { print ''; if ($lines[$i]->progress != '') { print getTaskProgressBadge($taskstatic); @@ -593,7 +593,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // resume - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) { print ''; if ($lines[$i]->progress != '' && $lines[$i]->duration) { print getTaskProgressView($taskstatic, false, false); @@ -604,25 +604,25 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showbilltime) { // Time not billed - if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; if ($lines[$i]->usage_bill_time) { print convertSecondToTime($lines[$i]->tobill, 'allhourmin'); $total_projectlinesa_tobill += $lines[$i]->tobill; } else { - print '' . $langs->trans("NA") . ''; + print ''.$langs->trans("NA").''; } print ''; } // Time billed - if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) { print ''; if ($lines[$i]->usage_bill_time) { print convertSecondToTime($lines[$i]->billed, 'allhourmin'); $total_projectlinesa_billed += $lines[$i]->billed; } else { - print '' . $langs->trans("NA") . ''; + print ''.$langs->trans("NA").''; } print ''; } @@ -650,12 +650,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Extra fields - $extrafieldsobjectkey=$taskstatic->table_element; - $obj=$lines[$i]; + $extrafieldsobjectkey = $taskstatic->table_element; + $obj = $lines[$i]; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$lines[$i]); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Tick to drag and drop @@ -693,18 +693,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; print ''.$langs->trans("Total").''; if ($showproject) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.label']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.dateo']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.datee']['checked'])) print ''; - if (count($arrayfields)>0 && !empty($arrayfields['t.planned_workload']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.dateo']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.datee']['checked'])) print ''; + if (count($arrayfields) > 0 && !empty($arrayfields['t.planned_workload']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.duration_effective']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.duration_effective']['checked'])) { print ''; if ($projectidfortotallink > 0) - print ''; + print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; @@ -734,27 +734,27 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_calculated']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { print ''; if ($total_projectlinesa_planned) - print $totalCalculatedProgress . ' %'; + print $totalCalculatedProgress.' %'; print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.progress']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { print ''; if ($total_projectlinesa_planned) - print '' . $totalAverageDeclaredProgress . ' %'; + print ''.$totalAverageDeclaredProgress.' %'; print ''; } // resume - if (count($arrayfields)>0 && !empty($arrayfields['t.progress_summary']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) { print ''; if ($total_projectlinesa_planned) { print ''; - print '
'; - print '
'; + print '
'; + print '
'; print '
'; print '
'; } @@ -763,12 +763,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($showbilltime) { - if (count($arrayfields)>0 && !empty($arrayfields['t.tobill']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.tobill']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_tobill, 'allhourmin'); print ''; } - if (count($arrayfields)>0 && !empty($arrayfields['t.billed']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['t.billed']['checked'])) { print ''; print convertSecondToTime($total_projectlinesa_billed, 'allhourmin'); print ''; @@ -2073,7 +2073,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $listofstatus = array_keys($listofoppstatus); - if (is_array($listofstatus) && ! empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { + if (is_array($listofstatus) && !empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) { // Define $themeColorId and array $statusOppList for each $listofstatus $themeColorId = 0; $statusOppList = array(); @@ -2216,7 +2216,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if ($userAccess >= 0) { $projectstatic->ref = $objp->ref; - $projectstatic->statut = $objp->status; // deprecated + $projectstatic->statut = $objp->status; // deprecated $projectstatic->status = $objp->status; $projectstatic->title = $objp->title; $projectstatic->datee = $db->jdate($objp->datee); diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 9e12e9d4229..fcdf4bbb79d 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -42,14 +42,14 @@ function propal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if ((empty($conf->commande->enabled) && ((! empty($conf->expedition->enabled) && ! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) - || (! empty($conf->expedition->enabled) && ! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) + if ((empty($conf->commande->enabled) && ((!empty($conf->expedition->enabled) && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) + || (!empty($conf->expedition->enabled) && !empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; - if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); - if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); + if ($conf->expedition_bon->enabled) $text = $langs->trans("Shipment"); + if ($conf->livraison_bon->enabled) $text .= '/'.$langs->trans("Receivings"); $head[$h][1] = $text; $head[$h][2] = 'shipping'; $h++; @@ -60,7 +60,7 @@ function propal_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -74,23 +74,23 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/core/lib/reception.lib.php b/htdocs/core/lib/reception.lib.php index 33591b3beea..3cf9a535eaa 100644 --- a/htdocs/core/lib/reception.lib.php +++ b/htdocs/core/lib/reception.lib.php @@ -60,7 +60,7 @@ function reception_prepare_head(Reception $object) $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -70,7 +70,7 @@ function reception_prepare_head(Reception $object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -103,7 +103,7 @@ function reception_admin_prepare_head() $h++; - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); @@ -111,7 +111,7 @@ function reception_admin_prepare_head() $h++; } - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) { $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 979583e8b4d..5a8d5d2530e 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -44,11 +44,11 @@ function report_header($reportname, $notused, $period, $periodlink, $description print "\n\n\n"; - if(! empty($varlink)) $varlink = '?'.$varlink; + if (!empty($varlink)) $varlink = '?'.$varlink; $head = array(); - $h=0; + $h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("Report"); $head[$h][2] = 'report'; @@ -58,7 +58,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description dol_fiche_head($head, 'report'); - foreach($moreparam as $key => $value) + foreach ($moreparam as $key => $value) { print ''."\n"; } diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 7bd2454dbe6..e6a0998ba6f 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -45,7 +45,7 @@ function resource_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -59,30 +59,30 @@ function resource_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->resource->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if($nbFiles > 0) $head[$h][1].= ''.$nbFiles.''; + if ($nbFiles > 0) $head[$h][1] .= ''.$nbFiles.''; $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index 01b3cafd60d..0e2328bc7e7 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -46,12 +46,12 @@ function salaries_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b9a606b98b4..04d16084365 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -221,7 +221,7 @@ if (!function_exists('dol_loginfunction')) // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; - $urllogo=DOL_URL_ROOT.'/theme/common/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 7f8de19e2e5..34dd845cdfa 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -37,7 +37,7 @@ function shipping_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings","deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -74,19 +74,19 @@ function shipping_prepare_head($object) $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -95,7 +95,7 @@ function shipping_prepare_head($object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -122,7 +122,7 @@ function delivery_prepare_head($object) global $langs, $db, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("sendings","deliveries")); + $langs->loadLangs(array("sendings", "deliveries")); $h = 0; $head = array(); @@ -165,12 +165,12 @@ function delivery_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($tmpobject->ref); + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($tmpobject->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $tmpobject->element, $tmpobject->id); + $nbLinks = Link::count($db, $tmpobject->element, $tmpobject->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$tmpobject->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -179,7 +179,7 @@ function delivery_prepare_head($object) if (!empty($tmpobject->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$tmpobject->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; @@ -206,29 +206,29 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') global $db, $conf, $langs; global $form; - $product_static=new Product($db); - $expedition=new Expedition($db); - $warehousestatic=new Entrepot($db); + $product_static = new Product($db); + $expedition = new Expedition($db); + $warehousestatic = new Entrepot($db); $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; + $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; + $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; - $sql.= ' p.description as product_desc'; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; + $sql .= ' p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; //TODO Add link to expeditiondet_batch - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql.= " AND obj.fk_".$origin." = ".$origin_id; - $sql.= " AND obj.rowid = ed.fk_origin_line"; - $sql.= " AND ed.fk_expedition = e.rowid"; - if ($filter) $sql.= $filter; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".$origin_id; + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; + if ($filter) $sql .= $filter; - $sql.= " ORDER BY obj.fk_product"; + $sql .= " ORDER BY obj.fk_product"; dol_syslog("show_list_sending_receive", LOG_DEBUG); $resql = $db->query($sql); @@ -250,7 +250,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$langs->trans("DateCreation").''; print ''.$langs->trans("DateDeliveryPlanned").''; print ''.$langs->trans("QtyPreparedOrShipped").''; - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''.$langs->trans("Warehouse").''; } @@ -260,7 +260,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; print ''; }*/ - if (! empty($conf->livraison_bon->enabled)) + if (!empty($conf->livraison_bon->enabled)) { print ''.$langs->trans("DeliveryOrder").''; //print ''.$langs->trans("QtyReceived").''; @@ -283,52 +283,52 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') if ($objp->fk_product > 0) { // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object = new $origin($db); $object->fetch($origin_id); $object->fetch_thirdparty(); $prod = new Product($db); - $prod->id=$objp->fk_product; + $prod->id = $objp->fk_product; $prod->getMultiLangs(); $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) + $newlang = ''; + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; } else { - $label = (! empty($objp->label)?$objp->label:$objp->product_label); + $label = (!empty($objp->label) ? $objp->label : $objp->product_label); } print ''; // Show product and description - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->fk_product; - $product_static->ref=$objp->ref; - $product_static->status_batch=$objp->product_tobatch; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); + $product_static->type = $objp->fk_product_type; + $product_static->id = $objp->fk_product; + $product_static->ref = $objp->ref; + $product_static->status_batch = $objp->product_tobatch; + $text = $product_static->getNomUrl(1); + $text .= ' - '.$label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($objp->date_start, $objp->date_end); // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (! empty($objp->description) && $objp->description!=$objp->product)?'
'.dol_htmlentitiesbr($objp->description):''; + print (!empty($objp->description) && $objp->description != $objp->product) ? '
'.dol_htmlentitiesbr($objp->description) : ''; } print ''; @@ -336,11 +336,11 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') else { print ""; - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'), 'service'); + if ($objp->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (! empty($objp->label)) { - $text.= ' '.$objp->label.''; + if (!empty($objp->label)) { + $text .= ' '.$objp->label.''; print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text.' '.nl2br($objp->description); @@ -363,7 +363,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''.$objp->qty_shipped.''; // Warehouse - if (! empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { print ''; if ($objp->warehouse_id > 0) @@ -407,17 +407,17 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') }*/ // Informations on receipt - if (! empty($conf->livraison_bon->enabled)) + if (!empty($conf->livraison_bon->enabled)) { include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; - $expedition->id=$objp->sendingid; + $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); //var_dump($expedition->linkedObjects); - $receiving=''; - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link + $receiving = ''; + if (count($expedition->linkedObjects['delivery']) > 0) $receiving = reset($expedition->linkedObjects['delivery']); // Take first link - if (! empty($receiving)) + if (!empty($receiving)) { // $expedition->fk_origin_line = id of det line of order // $receiving->fk_origin_line = id of det line of order diff --git a/htdocs/core/lib/supplier_proposal.lib.php b/htdocs/core/lib/supplier_proposal.lib.php index 6549b362c11..ddc85616ba6 100644 --- a/htdocs/core/lib/supplier_proposal.lib.php +++ b/htdocs/core/lib/supplier_proposal.lib.php @@ -34,7 +34,7 @@ function supplier_proposal_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("supplier_proposal","compta")); + $langs->loadLangs(array("supplier_proposal", "compta")); $h = 0; $head = array(); @@ -49,7 +49,7 @@ function supplier_proposal_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -63,23 +63,23 @@ function supplier_proposal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php index 6cf8189f3c8..8a883ceef91 100644 --- a/htdocs/core/lib/takepos.lib.php +++ b/htdocs/core/lib/takepos.lib.php @@ -47,7 +47,7 @@ function takepos_prepare_head() for ($i = 1; $i <= $numterminals; $i++) { $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i; - $head[$h][1] = $langs->trans("Terminal"). " ".$i; + $head[$h][1] = $langs->trans("Terminal")." ".$i; $head[$h][2] = 'terminal'.$i; $h++; } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index ade6a7f49cf..cdf9fe29b1c 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -54,12 +54,12 @@ function tax_prepare_head(ChargeSociales $object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->tax->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -93,131 +93,131 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di global $conf; // If we use date_start and date_end, we must not use $y, $m, $q - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) { dol_print_error('', 'Bad value of input parameter for tax_by_rate'); } - $list=array(); + $list = array(); if ($direction == 'sell') { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='ref'; + $invoicetable = 'facture'; + $invoicedettable = 'facturedet'; + $fk_facture = 'fk_facture'; + $fk_facture2 = 'fk_facture'; + $fk_payment = 'fk_paiement'; + $total_tva = 'total_tva'; + $paymenttable = 'paiement'; + $paymentfacturetable = 'paiement_facture'; + $invoicefieldref = 'ref'; } elseif ($direction == 'buy') { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; + $invoicetable = 'facture_fourn'; + $invoicedettable = 'facture_fourn_det'; + $fk_facture = 'fk_facture_fourn'; + $fk_facture2 = 'fk_facturefourn'; + $fk_payment = 'fk_paiementfourn'; + $total_tva = 'tva'; + $paymenttable = 'paiementfourn'; + $paymentfacturetable = 'paiementfourn_facturefourn'; + $invoicefieldref = 'ref'; } if (strpos($type, 'localtax') === 0) { - $f_rate = $type . '_tx'; + $f_rate = $type.'_tx'; } else { $f_rate = 'tva_tx'; } - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; + $total_localtax1 = 'total_localtax1'; + $total_localtax2 = 'total_localtax2'; // CAS DES BIENS/PRODUITS // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) return -1; + if (!$sql) return -1; if ($sql == 'TODO') return -2; if ($sql != 'TODO') { @@ -227,17 +227,17 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; @@ -262,7 +262,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; $list[$assoc['company_id']]['pid'][] = $assoc['pid']; $list[$assoc['company_id']]['pref'][] = $assoc['pref']; @@ -285,90 +285,90 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // CAS DES SERVICES // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -378,17 +378,17 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; @@ -438,40 +438,40 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($direction == 'buy') // buy only for expense reports { // Define sql request - $sql=''; + $sql = ''; // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; - $sql.= " WHERE e.entity = " . $conf->entity; - $sql.= " AND e.fk_statut in (6)"; + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; + $sql .= " WHERE e.entity = ".$conf->entity; + $sql .= " AND e.fk_statut in (6)"; if ($y && $m) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; - $sql.= " ORDER BY e.rowid"; + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = -1"; + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + $sql .= " ORDER BY e.rowid"; - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -481,18 +481,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($resql) { $company_id = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; - $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; + $oldrowid = $assoc['rowid']; + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; @@ -561,132 +561,132 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire global $conf; // If we use date_start and date_end, we must not use $y, $m, $q - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) { dol_print_error('', 'Bad value of input parameter for tax_by_rate'); } - $list=array(); + $list = array(); if ($direction == 'sell') { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='ref'; + $invoicetable = 'facture'; + $invoicedettable = 'facturedet'; + $fk_facture = 'fk_facture'; + $fk_facture2 = 'fk_facture'; + $fk_payment = 'fk_paiement'; + $total_tva = 'total_tva'; + $paymenttable = 'paiement'; + $paymentfacturetable = 'paiement_facture'; + $invoicefieldref = 'ref'; } else { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; + $invoicetable = 'facture_fourn'; + $invoicedettable = 'facture_fourn_det'; + $fk_facture = 'fk_facture_fourn'; + $fk_facture2 = 'fk_facturefourn'; + $fk_payment = 'fk_paiementfourn'; + $total_tva = 'tva'; + $paymenttable = 'paiementfourn'; + $paymentfacturetable = 'paiementfourn_facturefourn'; + $invoicefieldref = 'ref'; } - if ( strpos($type, 'localtax') === 0 ) { - $f_rate = $type . '_tx'; + if (strpos($type, 'localtax') === 0) { + $f_rate = $type.'_tx'; } else { $f_rate = 'tva_tx'; } - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; + $total_localtax1 = 'total_localtax1'; + $total_localtax2 = 'total_localtax2'; // CAS DES BIENS/PRODUITS // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 0"; // Limit to products - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 0"; // Limit to products + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) return -1; + if (!$sql) return -1; if ($sql == 'TODO') return -2; if ($sql != 'TODO') { @@ -696,18 +696,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; @@ -754,90 +754,90 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // CAS DES SERVICES // Define sql request - $sql=''; + $sql = ''; if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " 0 as payment_id, 0 as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; if ($y && $m) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture; } else { // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; - $sql.= " d.date_start as date_start, d.date_end as date_end,"; - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql.= " pa.datep as datep"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE f.entity IN (".getEntity($invoicetable).")"; - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) - 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.rowid = d.".$fk_facture; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql .= " d.date_start as date_start, d.date_end as date_end,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql .= " pa.datep as datep"; + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql .= " WHERE f.entity IN (".getEntity($invoicetable).")"; + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + 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.rowid = d.".$fk_facture; + $sql .= " AND s.rowid = f.fk_soc"; + $sql .= " AND pf.".$fk_facture2." = f.rowid"; + $sql .= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = 1"; // Limit to services - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = 1"; // Limit to services + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -847,18 +847,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; @@ -907,40 +907,40 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($direction == 'buy') // buy only for expense reports { // Define sql request - $sql=''; + $sql = ''; // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; - $sql.= " WHERE e.entity = " . $conf->entity; - $sql.= " AND e.fk_statut in (6)"; + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; + $sql .= " WHERE e.entity = ".$conf->entity; + $sql .= " AND e.fk_statut in (6)"; if ($y && $m) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; } elseif ($y) { - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; - $sql.= " ORDER BY e.rowid"; + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql .= " AND (d.product_type = -1"; + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + $sql .= " ORDER BY e.rowid"; - if (! $sql) + if (!$sql) { dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); - return -1; // -1 = Not accountancy module enabled + return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') @@ -950,20 +950,20 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($resql) { $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) + $oldrowid = ''; + while ($assoc = $db->fetch_array($resql)) { // Code to avoid warnings when array entry not defined - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { - $oldrowid=$assoc['rowid']; + $oldrowid = $assoc['rowid']; $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index fe7fb4ba5a7..e12531b3846 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -87,7 +87,7 @@ function ticket_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -95,13 +95,13 @@ function ticket_prepare_head($object) complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); // Attached files - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $upload_dir = $conf->ticket->dir_output . "/" . $object->ref; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->ticket->dir_output."/".$object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files')); - $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?id=' . $object->id; + $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); if ($nbFiles > 0) { - $head[$h][1] .= '' . $nbFiles . ''; + $head[$h][1] .= ''.$nbFiles.''; } $head[$h][2] = 'tabTicketDocument'; @@ -218,39 +218,39 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $width = 0; - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { // Print logo - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { - $urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); $width = 150; - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$mysoc->logo); $width = 150; - } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { - $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; + } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) { + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } } } print '
'; // Output html code for logo - if ($urllogo || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) + if ($urllogo || !empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { print '
'; print '
'; if ($urllogo) { - print ''; + print ''; print ''; print ''; } - if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { - print '
' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; + if (!empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + print '
'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).''; } print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { @@ -721,64 +721,64 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($user->rights->agenda->allactions->create || (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - $out.=''; + $out .= ''; } - $out.=''; + $out .= ''; // Date - $out.=' '; - $out.=dol_print_date($histo[$key]['datestart'], 'dayhour'); + $out .= ' '; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { - $tmpa=dol_getdate($histo[$key]['datestart'], true); - $tmpb=dol_getdate($histo[$key]['dateend'], true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'], 'hour'); - else $out.='-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour'); + else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); } - $late=0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($late) $out.=img_warning($langs->trans("Late")).' '; - $out.="\n"; + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($late) $out .= img_warning($langs->trans("Late")).' '; + $out .= "\n"; // Ref - $out.='

'; + $out .= '

'; // Author of event - $out.=''; + $out .= ''; if ($histo[$key]['userid'] > 0) { - if(!isset($userGetNomUrlCache[$histo[$key]['userid']])){ // is in cache ? + if (!isset($userGetNomUrlCache[$histo[$key]['userid']])) { // is in cache ? $userstatic->fetch($histo[$key]['userid']); $userGetNomUrlCache[$histo[$key]['userid']] = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } - $out.= $userGetNomUrlCache[$histo[$key]['userid']]; + $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } - $out.=''; + $out .= ''; // Title $out .= ' '; - if($actionstatic->code == 'TICKET_MSG') { + if ($actionstatic->code == 'TICKET_MSG') { $out .= $langs->trans('TicketNewMessage'); } - elseif($actionstatic->code == 'TICKET_MSG_PRIVATE') { + elseif ($actionstatic->code == 'TICKET_MSG_PRIVATE') { $out .= $langs->trans('TicketNewMessage').' ('.$langs->trans('Private').')'; - }else{ + } else { if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { - $transcode = $langs->trans("Action" . $histo[$key]['acode']); - $libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); $libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; $out .= dol_trunc($libelle, 120); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out .= '' . img_object($langs->trans("ShowEMailing"), "email") . ' '; - $transcode = $langs->trans("Action" . $histo[$key]['acode']); - $libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); $out .= dol_trunc($libelle, 120); } } @@ -835,25 +835,25 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($result > 0) { $footer .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $footer .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $footer .= '('.dol_print_phone($contact->phone_pro).')'; } } } - $documents = getTicketActionCommEcmList($actionstatic) ; - if(!empty($documents)) + $documents = getTicketActionCommEcmList($actionstatic); + if (!empty($documents)) { - $footer.= ''; } @@ -881,19 +881,19 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no - if(!empty($footer)){ - $out.=''; + if (!empty($footer)) { + $out .= ''; } - $out.='

'."\n"; // end timeline-item + $out .= '
'."\n"; // end timeline-item - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; $i++; } - $out.="\n"; + $out .= "\n"; } @@ -915,12 +915,12 @@ function getTicketActionCommEcmList($object) $documents = array(); $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; - $sql.= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\''; + $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; + $sql .= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\''; //$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type - $sql.= ' ORDER BY ecm.position ASC'; + $sql .= ' ORDER BY ecm.position ASC'; - $resql= $db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql)) { while ($obj = $db->fetch_object($resql)) { diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index cb4088c6bf2..0dcb6e8242d 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -35,19 +35,19 @@ */ function tree_showpad(&$fulltree, $key, $silent = 0) { - $pos=1; + $pos = 1; // Loop on each pos, because we will output an img for each pos while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) { // Process for column $pos - $atleastoneofthislevelafter=0; - $nbofdirinsub=0; - $nbofdocinsub=0; - $found=0; + $atleastoneofthislevelafter = 0; + $nbofdirinsub = 0; + $nbofdocinsub = 0; + $found = 0; //print 'x'.$key; - foreach($fulltree as $key2 => $val2) + foreach ($fulltree as $key2 => $val2) { //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; if ($found == 1) // We are after the entry to show @@ -55,11 +55,11 @@ function tree_showpad(&$fulltree, $key, $silent = 0) if ($fulltree[$key2]['level'] > $pos) { $nbofdirinsub++; - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub += $fulltree[$key2]['cachenbofdoc']; } if ($fulltree[$key2]['level'] == $pos) { - $atleastoneofthislevelafter=1; + $atleastoneofthislevelafter = 1; } if ($fulltree[$key2]['level'] <= $pos) { @@ -68,12 +68,12 @@ function tree_showpad(&$fulltree, $key, $silent = 0) } if ($key2 == $key) // We found ourself, so now every lower level will be counted { - $found=1; + $found = 1; } } //print $atleastoneofthislevelafter; - if (! $silent) + if (!$silent) { if ($atleastoneofthislevelafter) { @@ -89,7 +89,7 @@ function tree_showpad(&$fulltree, $key, $silent = 0) $pos++; } - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); + return array($atleastoneofthislevelafter, $nbofdirinsub, $nbofdocinsub); } @@ -117,7 +117,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset { global $tree_recur_alreadyadded, $menu_handler_to_search; - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); + if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded = array(); if ($rang == 0) { @@ -141,30 +141,30 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset if ($rang > 50) { - return; // Protect against infinite loop. Max 50 depth + return; // Protect against infinite loop. Max 50 depth } //ballayage du tableau - $sizeoftab=count($tab); - $ulprinted=0; - for ($x=0; $x < $sizeoftab; $x++) + $sizeoftab = count($tab); + $ulprinted = 0; + for ($x = 0; $x < $sizeoftab; $x++) { //var_dump($tab[$x]);exit; // If an element has $pere for parent if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) { //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
\n"; - if (empty($ulprinted) && ! empty($pere['rowid'])) + if (empty($ulprinted) && !empty($pere['rowid'])) { - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); continue; } - print ''; $ulprinted++; + print ''; $ulprinted++; } - print "\n".'
  • '; + print "\n".'
  • '; if ($showfk) { print ''; // Year print ''; @@ -251,11 +251,11 @@ print ''; print '';*/ print ''; -$oldyear=0; +$oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while (! empty($year) && $oldyear > $year+1) + while (!empty($year) && $oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; @@ -273,7 +273,7 @@ foreach ($data as $val) /*print ''; print '';*/ print ''; - $oldyear=$year; + $oldyear = $year; } print '
    '; @@ -180,26 +180,26 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print $tab[$x]['entry']; } //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
    '."\n"; - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); // And now we search all its sons of lower level - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); print ''; } - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) + elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) { //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."
    \n"; - if (empty($ulprinted) && ! empty($pere['rowid'])) + if (empty($ulprinted) && !empty($pere['rowid'])) { - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; continue; } - print ''; $ulprinted++; + print ''; $ulprinted++; } - print "\n".'
  • '; + print "\n".'
  • '; if ($showfk) { print ''; print ''; - print ''; print ''; - print ''; print ''; @@ -685,7 +685,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); + $default = (empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); print ''; print ''; @@ -698,7 +698,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } - print '   ('.$langs->trans("Default").': '.$default.') '; // $colorbacktitle1 in CSS + print '   ('.$langs->trans("Default").': '.$default.') '; // $colorbacktitle1 in CSS print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; @@ -712,7 +712,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); + $default = (empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); print ''; print ''; @@ -739,11 +739,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); + $default = (empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); print ''; print ''; - print ''; print ''; - print ''; print ''; @@ -857,22 +857,22 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) */ } else { - $default=(empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover))); + $default = (empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover))); print ''; print ''; - print ''; print ''; diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php index 1649e686ec2..0bc3bb66e90 100644 --- a/htdocs/core/lib/vat.lib.php +++ b/htdocs/core/lib/vat.lib.php @@ -49,12 +49,12 @@ function vat_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->tax->dir_output . "/vat/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->tax->dir_output."/vat/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; $head[$tab][2] = 'documents'; $tab++; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 0822109d45e..af8840b33ae 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -562,7 +562,7 @@ function getStructuredData($type, $data = array()) } elseif ($type == 'blogpost') { - if (! empty($websitepage->author_alias)) + if (!empty($websitepage->author_alias)) { //include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; //$tmpuser = new User($db); @@ -665,24 +665,24 @@ function getSocialNetworkSharingLinks() $hashtags = trim(join(' #', array_map('trim', explode(',', $websitepage->keywords)))); $out = ''."\n"; - $out.= ' -global->MAIN_VIEW_LINE_NUMBER)) { ?> - +global->MAIN_VIEW_LINE_NUMBER)) { ?> + info_bits & 2) != 2) { - print 'fk_prev_id != null ) print ' readonly'; + print 'fk_prev_id != null) print ' readonly'; print '>%'; } else { ?>   @@ -216,7 +216,7 @@ $coldisplay++; ?> - global->MAIN_VIEW_LINE_NUMBER)) { ?> + global->MAIN_VIEW_LINE_NUMBER)) { ?> - "; print "\n"; - if ( $object->socid && ! empty($conf->societe->enabled) && ! empty($conf->global->DONATION_USE_THIRDPARTIES) ) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + if ($object->socid && !empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) { + $company = new Societe($db); + $result = $company->fetch($object->socid); print ''; } else { @@ -547,14 +547,14 @@ if (!empty($id) && $action == 'edit') // Zip / Town print ''; // Country print ''; if ($object->socid) { - $company=new Societe($db); - $result=$company->fetch($object->socid); + $company = new Societe($db); + $result = $company->fetch($object->socid); print ''; } else { @@ -865,7 +865,7 @@ if (!empty($id) && $action != 'edit') $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT && { diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 95ea92f1ff3..872e2009b9b 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -63,16 +63,16 @@ class Donations extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->don->lire) { + if (!DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -109,33 +109,33 @@ class Donations extends DolibarrApi $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."don as t"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."don as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; + $sql .= ' WHERE t.entity IN ('.getEntity('don').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($thirdparty_ids) $sql .= " AND t.fk_soc = ".$thirdparty_ids." "; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -145,12 +145,12 @@ class Donations extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $don_static = new Don($db); - if($don_static->fetch($obj->rowid)) { + if ($don_static->fetch($obj->rowid)) { // Add external contacts ids //$don_static->contacts_ids = $don_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($don_static); @@ -161,7 +161,7 @@ class Donations extends DolibarrApi else { throw new RestException(503, 'Error when retrieve donation list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No donation found'); } @@ -176,7 +176,7 @@ class Donations extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -210,16 +210,16 @@ class Donations extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } $result = $this->don->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -245,19 +245,19 @@ class Donations extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->don->supprimer) { + if (!DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->don->delete(DolibarrApiAccess::$user)) { + if (!$this->don->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete donation : '.$this->don->error); } @@ -293,15 +293,15 @@ class Donations extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Donation not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -313,11 +313,11 @@ class Donations extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->don->error); } $result = $this->don->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('don', $this->don->id)) { + if (!DolibarrApi::_checkAccessToResource('don', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -360,7 +360,7 @@ class Donations extends DolibarrApi $don = array(); foreach (Orders::$FIELDS as $field) { if (!isset($data[$field])) - throw new RestException(400, $field ." field missing"); + throw new RestException(400, $field." field missing"); $don[$field] = $data[$field]; } return $don; diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 607d6555337..5370bdcaf73 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -24,9 +24,9 @@ * \brief File of class to manage donations statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -76,15 +76,15 @@ class DonationStats extends Stats $this->userid = $userid; $this->cachefilesuffix = $mode; - $object=new Don($this->db); + $object = new Don($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as d"; //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; //$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE - $this->where.= " d.fk_statut > 0"; // Not draft and not cancelled + $this->where .= " d.fk_statut > 0"; // Not draft and not cancelled //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= " AND d.entity = ".$conf->entity; - if ($this->userid > 0) $this->where.=' WHERE c.fk_user_author = '.$this->userid; + $this->where .= " AND d.entity = ".$conf->entity; + if ($this->userid > 0) $this->where .= ' WHERE c.fk_user_author = '.$this->userid; } /** @@ -99,13 +99,13 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -120,10 +120,10 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -138,10 +138,10 @@ class DonationStats extends Stats global $user; $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 22b75cd777b..ee8156c229e 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -32,12 +32,12 @@ class PaymentDonation extends CommonObject /** * @var string ID to identify managed object */ - public $element='payment_donation'; + public $element = 'payment_donation'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='payment_donation'; + public $table_element = 'payment_donation'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -54,11 +54,11 @@ class PaymentDonation extends CommonObject */ public $fk_donation; - public $datec=''; - public $tms=''; - public $datep=''; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts + public $datec = ''; + public $tms = ''; + public $datep = ''; + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts public $typepayment; public $num_payment; @@ -109,23 +109,23 @@ class PaymentDonation extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Validate parameters - if (! $this->datepaid) + if (!$this->datepaid) { - $this->error='ErrorBadValueForParameterCreatePaymentDonation'; + $this->error = 'ErrorBadValueForParameterCreatePaymentDonation'; return -1; } // Clean parameters if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -148,15 +148,15 @@ class PaymentDonation extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,"; - $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaid)."',"; - $sql.= " ".$totalamount.","; - $sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".$user->id.","; - $sql.= " 0)"; + $sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaid)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".$user->id.","; + $sql .= " 0)"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation"); @@ -168,24 +168,24 @@ class PaymentDonation extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_CREATE', $user); + $result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if ($totalamount != 0 && ! $error) + if ($totalamount != 0 && !$error) { - $this->amount=$totalamount; - $this->total=$totalamount; // deprecated + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -201,27 +201,27 @@ class PaymentDonation extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_donation,"; - $sql.= " t.datec,"; - $sql.= " t.tms,"; - $sql.= " t.datep,"; - $sql.= " t.amount,"; - $sql.= " t.fk_typepayment,"; - $sql.= " t.num_payment,"; - $sql.= " t.note as note_public,"; - $sql.= " t.fk_bank,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_modif,"; - $sql.= " pt.code as type_code, pt.libelle as type_label,"; - $sql.= ' b.fk_account'; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_donation,"; + $sql .= " t.datec,"; + $sql .= " t.tms,"; + $sql .= " t.datep,"; + $sql .= " t.amount,"; + $sql .= " t.fk_typepayment,"; + $sql .= " t.num_payment,"; + $sql .= " t.note as note_public,"; + $sql .= " t.fk_bank,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_modif,"; + $sql .= " pt.code as type_code, pt.libelle as type_label,"; + $sql .= ' b.fk_account'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -231,23 +231,23 @@ class PaymentDonation extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->fk_donation = $obj->fk_donation; + $this->fk_donation = $obj->fk_donation; $this->datec = $this->db->jdate($obj->datec); - $this->tms = $this->db->jdate($obj->tms); + $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); - $this->amount = $obj->amount; - $this->fk_typepayment = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->note_public = $obj->note_public; - $this->fk_bank = $obj->fk_bank; + $this->amount = $obj->amount; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->note_public = $obj->note_public; + $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; - $this->type_code = $obj->type_code; - $this->type_label = $obj->type_label; + $this->type_code = $obj->type_code; + $this->type_label = $obj->type_label; - $this->bank_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; } $this->db->free($resql); @@ -255,7 +255,7 @@ class PaymentDonation extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -271,15 +271,15 @@ class PaymentDonation extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); - if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -289,36 +289,36 @@ class PaymentDonation extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET"; - $sql.= " fk_donation=".(isset($this->fk_donation)?$this->fk_donation:"null").","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; - $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; - $sql.= " note=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; - $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; - $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; - $sql.= " WHERE rowid=".(int) $this->id; + $sql .= " fk_donation=".(isset($this->fk_donation) ? $this->fk_donation : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").","; + $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; + $sql .= " note=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_MODIFY', $user); + $result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -328,13 +328,13 @@ class PaymentDonation extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -354,41 +354,41 @@ class PaymentDonation extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_donation' AND url_id=".(int) $this->id; + $sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('DONATION_PAYMENT_DELETE', $user); + $result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -398,13 +398,13 @@ class PaymentDonation extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -424,39 +424,39 @@ class PaymentDonation extends CommonObject */ public function createFromClone(User $user, $fromid) { - $error=0; + $error = 0; - $object=new PaymentDonation($this->db); + $object = new PaymentDonation($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); - $object->id=0; - $object->statut=0; + $object->id = 0; + $object->statut = 0; // Clear fields // ... // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } - if (! $error) + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -506,19 +506,19 @@ class PaymentDonation extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_donation=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepayment=''; - $this->num_payment=''; - $this->note_public=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_donation = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepayment = ''; + $this->num_payment = ''; + $this->note_public = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; } @@ -538,22 +538,22 @@ class PaymentDonation extends CommonObject { global $conf; - $error=0; + $error = 0; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_donation') $amount=$total; + $total = $this->total; + if ($mode == 'payment_donation') $amount = $total; // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaid, - $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, $amount, $this->num_payment, @@ -567,7 +567,7 @@ class PaymentDonation extends CommonObject // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { - $result=$this->update_fk_bank($bank_line_id); + $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; @@ -575,11 +575,11 @@ class PaymentDonation extends CommonObject } // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/don/payment/card.php?rowid='; + $url = ''; + if ($mode == 'payment_donation') $url = DOL_URL_ROOT.'/don/payment/card.php?rowid='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; @@ -589,12 +589,12 @@ class PaymentDonation extends CommonObject } else { - $this->error=$acc->error; + $this->error = $acc->error; $error++; } } - if (! $error) + if (!$error) { return 1; } @@ -625,7 +625,7 @@ class PaymentDonation extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return 0; } } @@ -641,18 +641,18 @@ class PaymentDonation extends CommonObject { global $langs; - $result=''; + $result = ''; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/don/document.php b/htdocs/don/document.php index dba5b4cff7b..8dbb6f99fda 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -50,7 +50,7 @@ $confirm = GETPOST('confirm', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'don', $id, ''); @@ -101,27 +101,27 @@ if ($object->id) { $object->fetch_thirdparty(); - $head=donation_prepare_head($object); + $head = donation_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -129,28 +129,28 @@ if ($object->id) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/don/info.php b/htdocs/don/info.php index e2249e082a7..cff4aceae79 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -34,12 +34,12 @@ if (!empty($conf->projet->enabled)) $langs->load("donations"); $id = GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'don', $id, ''); $object = new Don($db); @@ -69,14 +69,14 @@ $head = donation_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("Donation"), -1, 'generic'); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
    '; +$morehtmlref = '
    '; // Project -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -84,28 +84,28 @@ if (! empty($conf->projet->enabled)) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } -$morehtmlref.='
    '; +$morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index 128ea2163c7..08b8c05b520 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -29,35 +29,35 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("companies","bills","donations")); +$langs->loadLangs(array("companies", "bills", "donations")); -$id=(GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('facid', 'int')); // For backward compatibility -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check -$socid=0; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'don', $id, ''); +$socid = 0; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'don', $id, ''); $object = new Don($db); $object->fetch($id); -$permissionnote=$user->rights->don->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->don->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once if ($action == 'classin' && $user->rights->don->creer) { @@ -85,14 +85,14 @@ if ($id > 0 || !empty($ref)) dol_fiche_head($head, 'note', $langs->trans("Donation"), -1, 'generic'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { @@ -100,35 +100,35 @@ if ($id > 0 || !empty($ref)) } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); print '
    '; print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index c5517a72696..0017f0a8556 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -27,24 +27,24 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; -if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","banks","companies")); +$langs->loadLangs(array("bills", "banks", "companies")); // Security check -$id=GETPOST('rowid')?GETPOST('rowid', 'int'):GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +if ($user->socid) $socid = $user->socid; // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentDonation($db); if ($id > 0) { - $result=$object->fetch($id); - if (! $result) dol_print_error($db, 'Failed to get payment id '.$id); + $result = $object->fetch($id); + if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); } @@ -76,20 +76,20 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->cree { $db->begin(); - $result=$object->valide(); + $result = $object->valide(); if ($result > 0) { $db->commit(); - $factures=array(); // TODO Get all id of invoices linked to this payment - foreach($factures as $id) + $factures = array(); // TODO Get all id of invoices linked to this payment + foreach ($factures as $id) { $fac = new Facture($db); $fac->fetch($id); $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) + if (!empty($_REQUEST['lang_id'])) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); @@ -119,7 +119,7 @@ llxHeader(); $don = new Don($db); $form = new Form($db); -$h=0; +$h = 0; $head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("Card"); @@ -176,11 +176,11 @@ print '
    '; // Bank account -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { if ($object->bank_account) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); print ''; @@ -201,13 +201,13 @@ print '
    '; @@ -216,14 +216,14 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset print $tab[$x]['entry']; } //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
    '."\n"; - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); // And now we search all its sons of lower level //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."
    \n"; - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); print ''; } } - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print ''."\n"; } + if (!empty($ulprinted) && !empty($pere['rowid'])) { print ''."\n"; } if ($rang == 0) print ''; } diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index cb54b263a00..ec8c6a6858f 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -34,7 +34,7 @@ function trip_prepare_head(Deplacement $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -50,7 +50,7 @@ function trip_prepare_head(Deplacement $object) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2b510373299..bc20612c747 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -582,11 +582,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1))); + $default = (empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1))); print '
    '.$langs->trans("TopMenuBackgroundColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', 'formcolor', 1).' '; @@ -630,11 +630,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1))); + $default = (empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1))); print '
    '.$langs->trans("LeftMenuBackgroundColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', 'formcolor', 1).' '; @@ -658,7 +658,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); + $default = (empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); print '
    '.$langs->trans("TextTitleColor").'
    '.$langs->trans("BackgroundTableTitleColor").'
    '.$langs->trans("BackgroundTableTitleTextColor").'
    '.$langs->trans("BackgroundTableLineOddColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', 'formcolor', 1).' '; @@ -767,11 +767,11 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); + $default = (empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); print '
    '.$langs->trans("BackgroundTableLineEvenColor").''; + print ''; if ($edit) { print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', 'formcolor', 1).' '; @@ -815,7 +815,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink))); + $default = (empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink))); print '
    '.$langs->trans("LinkColor").'
    '.$langs->trans("HighlightLinesColor").''; + print ''; //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; if ($edit) { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1).' '; } else { - if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover)); + if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); if ($color) { @@ -903,7 +903,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { - $default=(empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); + $default = (empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); print '
    '.$langs->trans("HighlightLinesChecked").'
    - product->enabled) || ! empty($conf->service->enabled)) { ?> + product->enabled) || !empty($conf->service->enabled)) { ?> @@ -264,17 +264,17 @@ if (!empty($extrafields)) } ?> -service->enabled) && $line->product_type == 1 && $dateSelector) { ?> +service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
    trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); - print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateline", 1, 0); + $hourmin = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : ''); + print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start ? 0 : 1, "updateline", 1, 0); print ' '.$langs->trans('to').' '; - print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end?0:1, "updateline", 1, 0); + print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end ? 0 : 1, "updateline", 1, 0); print '"; -print ''; -print ''; +print ''; +print ''; print ''; print ''; if ($conf->global->MAIN_MULTILANGS) { - print ''; } -$subject = 'DATAPOLICIESSUBJECT_' . $l; -$linka = 'TXTLINKDATAPOLICIESACCEPT_' . $l; -$linkr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; -$content = 'DATAPOLICIESCONTENT_' . $l; -$acc = 'DATAPOLICIESACCEPT_' . $l; -$ref = 'DATAPOLICIESREFUSE_' . $l; +$subject = 'DATAPOLICIESSUBJECT_'.$l; +$linka = 'TXTLINKDATAPOLICIESACCEPT_'.$l; +$linkr = 'TXTLINKDATAPOLICIESREFUSE_'.$l; +$content = 'DATAPOLICIESCONTENT_'.$l; +$acc = 'DATAPOLICIESACCEPT_'.$l; +$ref = 'DATAPOLICIESREFUSE_'.$l; print ''; print ''; print ''; print ''; print ''; print '
    ' . $form->editfieldkey('DefaultLang', 'default_lang', '', null, 0) . '' . "\n"; + print '
    '.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).''."\n"; print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print '
    '; -print $langs->trans('DATAPOLICIESSUBJECTMAIL') . ''; -print ''; +print $langs->trans('DATAPOLICIESSUBJECTMAIL').''; +print ''; print '
    '; print $langs->trans('DATAPOLICIESCONTENTMAIL').''; -print $langs->trans('DATAPOLICIESSUBSITUTION');echo'__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__'; +print $langs->trans('DATAPOLICIESSUBSITUTION'); echo'__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__'; $doleditor = new DolEditor($content, $conf->global->$content, '', 250, 'Full', '', false, true, 1, 200, 70); $doleditor->Create(); print '
    '; -print $langs->trans('TXTLINKDATAPOLICIESACCEPT') . ''; -print ''; +print $langs->trans('TXTLINKDATAPOLICIESACCEPT').''; +print ''; print '
    '; -print $langs->trans('TXTLINKDATAPOLICIESREFUSE') . ''; -print ''; +print $langs->trans('TXTLINKDATAPOLICIESREFUSE').''; +print ''; print '
    '; @@ -149,7 +149,7 @@ $doleditor->Create(); print '
    '; -print '
    '; +print '
    '; print ''; diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 7d467729841..3ef5a12d720 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -133,22 +133,22 @@ class ActionsDatapolicy header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); header('Pragma: no-cache'); $object->fetch(GETPOST('socid')); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->name . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->name.';'; echo ';'; echo ';'; echo ';'; echo ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone . ';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone.';'; echo ';'; echo ';'; - echo $object->skype . ';'; + echo $object->skype.';'; echo ';'; exit; } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicy_portabilite') { @@ -157,23 +157,23 @@ class ActionsDatapolicy header('Pragma: no-cache'); $soc = $object->fetch_thirdparty(); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->lastname . ';'; - echo $object->firstname . ';'; - echo $object->getCivilityLabel() . ';'; - echo ($soc != -1 ? $object->thirdparty->name : '') . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->lastname.';'; + echo $object->firstname.';'; + echo $object->getCivilityLabel().';'; + echo ($soc != -1 ? $object->thirdparty->name : '').';'; echo ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone . ';'; - echo $object->phone_perso . ';'; - echo $object->phone_mobile . ';'; - echo $object->skype . ';'; - echo dol_print_date($object->birth) . ';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone.';'; + echo $object->phone_perso.';'; + echo $object->phone_mobile.';'; + echo $object->skype.';'; + echo dol_print_date($object->birth).';'; exit; } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicy_portabilite') { $object->fetch(GETPOST('id')); @@ -181,39 +181,39 @@ class ActionsDatapolicy header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); header('Pragma: no-cache'); $soc = $object->fetch_thirdparty(); - echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;' . PHP_EOL; - echo $object->lastname . ';'; - echo $object->firstname . ';'; - echo $object->getCivilityLabel() . ';'; - echo ($soc != -1 ? $object->thirdparty->name : '') . ';'; - echo $object->poste . ';'; - echo $object->address . ';'; - echo $object->zip . ';'; - echo $object->town . ';'; - echo $object->state . ';'; - echo $object->country . ';'; - echo $object->email . ';'; - echo $object->phone_pro . ';'; - echo $object->phone_perso . ';'; - echo $object->phone_mobile . ';'; - echo $object->jabberid . ';'; - echo dol_print_date($object->birth) . ';'; + echo 'Name;Fistname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; + echo $object->lastname.';'; + echo $object->firstname.';'; + echo $object->getCivilityLabel().';'; + echo ($soc != -1 ? $object->thirdparty->name : '').';'; + echo $object->poste.';'; + echo $object->address.';'; + echo $object->zip.';'; + echo $object->town.';'; + echo $object->state.';'; + echo $object->country.';'; + echo $object->email.';'; + echo $object->phone_pro.';'; + echo $object->phone_perso.';'; + echo $object->phone_mobile.';'; + echo $object->jabberid.';'; + echo dol_print_date($object->birth).';'; exit; } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('id')); - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyContact($object); } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('id')); - require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyAdherent($object); } elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('socid')); - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/datapolicy/class/datapolicy.class.php'; DataPolicy::sendMailDataPolicyCompany($object); } @@ -278,7 +278,7 @@ class ActionsDatapolicy /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' - $this->resprints = ''; + $this->resprints = ''; } if (!$error) { @@ -308,7 +308,7 @@ class ActionsDatapolicy $ret = 0; $deltemp = array(); - dol_syslog(get_class($this) . '::executeHooks action=' . $action); + dol_syslog(get_class($this).'::executeHooks action='.$action); /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' @@ -332,10 +332,10 @@ class ActionsDatapolicy global $conf, $user, $langs; $langs->load('datapolicy@datapolicy'); - if (! empty($conf->global->DATAPOLICIES_ENABLE_EMAILS)) + if (!empty($conf->global->DATAPOLICIES_ENABLE_EMAILS)) { - $dialog = '
    '.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
    '.$langs->trans('Country').''; - print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code), 'country_id'); + print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id'); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -634,43 +634,43 @@ if (!empty($id) && $action != 'edit') // Print form confirm print $formconfirm; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; if ($user->rights->don->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref.=''; - $morehtmlref.='
    '; + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= ''; + $morehtmlref .= '
    '; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -696,8 +696,8 @@ if (!empty($id) && $action != 'edit') print '
    '.$langs->trans("LinkedToDolibarrThirdParty").''.$company->getNomUrl(1).'
    '.$langs->trans('Amount').''.price($object->amount, 0, $ print '
    '.$langs->trans('Note').''.nl2br($object->note_public).'
    '; $disable_delete = 0; $sql = 'SELECT d.rowid as did, d.paid, d.amount as d_amount, pd.amount'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_donation as pd,'.MAIN_DB_PREFIX.'don as d'; -$sql.= ' WHERE pd.fk_donation = d.rowid'; -$sql.= ' AND d.entity = '.$conf->entity; -$sql.= ' AND pd.rowid = '.$id; +$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_donation as pd,'.MAIN_DB_PREFIX.'don as d'; +$sql .= ' WHERE pd.fk_donation = d.rowid'; +$sql .= ' AND d.entity = '.$conf->entity; +$sql .= ' AND pd.rowid = '.$id; dol_syslog("don/payment/card.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -286,7 +286,7 @@ if (empty($action)) { if ($user->rights->don->supprimer) { - if (! $disable_delete) + if (!$disable_delete) { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 182f7697601..46b0d93d564 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -29,11 +29,11 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/donstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$userid=GETPOST('userid', 'int'); -$socid=GETPOST('socid', 'int'); +$userid = GETPOST('userid', 'int'); +$socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { @@ -41,21 +41,21 @@ if ($user->socid > 0) $socid = $user->socid; } -$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; // Load translation files required by the page -$langs->loadLangs(array("companies","other","sendings")); +$langs->loadLangs(array("companies", "other", "sendings")); /* * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -64,7 +64,7 @@ print load_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg); dol_mkdir($dir); -$stats = new DonationStats($db, $socid, '', ($userid>0?$userid:0)); +$stats = new DonationStats($db, $socid, '', ($userid > 0 ? $userid : 0)); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); @@ -83,13 +83,13 @@ else $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); @@ -100,7 +100,7 @@ if (! $mesg) $px1->SetYLabel($langs->trans("NbOfSendings")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -188,22 +188,22 @@ if (! $mesg) // Show array $data = $stats->getAllByYear(); -$arrayyears=array(); -foreach($data as $val) { - if (! empty($val['year'])) { - $arrayyears[$val['year']]=$val['year']; +$arrayyears = array(); +foreach ($data as $val) { + if (!empty($val['year'])) { + $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 . '/don/stats/index.php'; +$head[$h][0] = DOL_URL_ROOT.'/don/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -$type='donation_stats'; +$type = 'donation_stats'; complete_head_from_modules($conf, $langs, null, $head, $h, $type); @@ -231,8 +231,8 @@ print '
    '; print '
  • '.$langs->trans("Year").''; - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0); print '
    '.$langs->trans("NbOfSendings").''.$langs->trans("AmountAverage").'
    '.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
    '; diff --git a/htdocs/don/tpl/linkedobjectblock.tpl.php b/htdocs/don/tpl/linkedobjectblock.tpl.php index 94a676f964d..18c410ba4d0 100644 --- a/htdocs/don/tpl/linkedobjectblock.tpl.php +++ b/htdocs/don/tpl/linkedobjectblock.tpl.php @@ -29,13 +29,13 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("donations"); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) { +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; print ''; print ''.$langs->trans("Donation").''; print ''.$objectlink->getNomUrl(1).''; @@ -52,7 +52,7 @@ print ''; if (count($linkedObjectBlock) > 1) { ?> - + trans("Total"); ?> diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index 754f68a9930..9f4820cd723 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -20,15 +20,15 @@ * \brief File to build ecm database */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $element = GETPOST('element', 'alpha'); /* @@ -40,13 +40,13 @@ top_httphead(); //print ''."\n"; // Load original field value -if (isset($action) && ! empty($action)) +if (isset($action) && !empty($action)) { - $error=0; + $error = 0; - if ($action == 'build' && ! empty($element)) + if ($action == 'build' && !empty($element)) { - require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; + require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; $ecmdirstatic = new EcmDirectory($db); $ecmdirtmp = new EcmDirectory($db); @@ -54,57 +54,57 @@ if (isset($action) && ! empty($action)) // This part of code is same than into file index.php for action refreshmanual TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->$element->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->$element->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->$element->dir_output, 'directories', 1, '', array('^temp$'), '', '', 0); + $disktree = dol_dir_list($conf->$element->dir_output, 'directories', 1, '', array('^temp$'), '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { set_time_limit(0); // To force restarts the timeout counter from zero - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->$element->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -112,7 +112,7 @@ if (isset($action) && ! empty($action)) { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -124,7 +124,7 @@ if (isset($action) && ! empty($action)) else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -134,20 +134,20 @@ if (isset($action) && ! empty($action)) $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $txt."
    \n"; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -155,7 +155,7 @@ if (isset($action) && ! empty($action)) } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -163,19 +163,19 @@ if (isset($action) && ! empty($action)) } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
    \n"; - $ecmdirtmp->id=$dirdesc['id']; + $mesg .= $dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
    \n"; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index c8c67f82b9c..3bddd70bfaa 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -30,7 +30,7 @@ class EcmDirectory // extends CommonObject /** * @var string ID to identify managed object */ - public $element='ecm_directories'; + public $element = 'ecm_directories'; /** * @var string Name of table without prefix where object is stored @@ -62,7 +62,7 @@ class EcmDirectory // extends CommonObject */ public $description; - public $cachenbofdoc=-1; // By default cache initialized with value 'not calculated' + public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated' public $date_c; public $date_m; @@ -81,11 +81,11 @@ class EcmDirectory // extends CommonObject */ public $ref; - public $cats=array(); - public $motherof=array(); + public $cats = array(); + public $motherof = array(); - public $forbiddenchars = array('<','>',':','/','\\','?','*','|','"'); - public $forbiddencharsdir = array('<','>',':','?','*','|','"'); + public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"'); + public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"'); public $full_arbo_loaded; @@ -122,46 +122,46 @@ class EcmDirectory // extends CommonObject { global $conf, $langs; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->label=dol_sanitizeFileName(trim($this->label)); - $this->fk_parent=trim($this->fk_parent); - $this->description=trim($this->description); - $this->date_c=$now; - $this->fk_user_c=$user->id; - if ($this->fk_parent <= 0) $this->fk_parent=0; + $this->label = dol_sanitizeFileName(trim($this->label)); + $this->fk_parent = trim($this->fk_parent); + $this->description = trim($this->description); + $this->date_c = $now; + $this->fk_user_c = $user->id; + if ($this->fk_parent <= 0) $this->fk_parent = 0; // Check if same directory does not exists with this name - $relativepath=$this->label; + $relativepath = $this->label; if ($this->fk_parent) { $parent = new EcmDirectory($this->db); $parent->fetch($this->fk_parent); - $relativepath=$parent->getRelativePath().$relativepath; + $relativepath = $parent->getRelativePath().$relativepath; } - $relativepath=preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \ + $relativepath = preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \ //print $relativepath.'
    '; $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(1); - $pathfound=0; + $pathfound = 0; foreach ($cate_arbo as $key => $categ) { - $path=str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); + $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); //print $relativepath.' - '.$path.'
    '; if ($path == $relativepath) { - $pathfound=1; + $pathfound = 1; break; } } if ($pathfound) { - $this->error="ErrorDirAlreadyExists"; + $this->error = "ErrorDirAlreadyExists"; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); return -1; } @@ -171,39 +171,39 @@ class EcmDirectory // extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories("; - $sql.= "label,"; - $sql.= "entity,"; - $sql.= "fk_parent,"; - $sql.= "description,"; - $sql.= "cachenbofdoc,"; - $sql.= "date_c,"; - $sql.= "fk_user_c"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->escape($this->label)."',"; - $sql.= " '".$this->db->escape($conf->entity)."',"; - $sql.= " '".$this->db->escape($this->fk_parent)."',"; - $sql.= " '".$this->db->escape($this->description)."',"; - $sql.= " ".$this->cachenbofdoc.","; - $sql.= " '".$this->db->idate($this->date_c)."',"; - $sql.= " '".$this->db->escape($this->fk_user_c)."'"; - $sql.= ")"; + $sql .= "label,"; + $sql .= "entity,"; + $sql .= "fk_parent,"; + $sql .= "description,"; + $sql .= "cachenbofdoc,"; + $sql .= "date_c,"; + $sql .= "fk_user_c"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->escape($this->label)."',"; + $sql .= " '".$this->db->escape($conf->entity)."',"; + $sql .= " '".$this->db->escape($this->fk_parent)."',"; + $sql .= " '".$this->db->escape($this->description)."',"; + $sql .= " ".$this->cachenbofdoc.","; + $sql .= " '".$this->db->idate($this->date_c)."',"; + $sql .= " '".$this->db->escape($this->fk_user_c)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories"); - $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); - $result=dol_mkdir($dir); - if ($result < 0) { $error++; $this->error="ErrorFailedToCreateDir"; } + $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); + $result = dol_mkdir($dir); + if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; } // Call trigger - $result=$this->call_trigger('MYECMDIR_CREATE', $user); + $result = $this->call_trigger('MYECMDIR_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -216,7 +216,7 @@ class EcmDirectory // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } @@ -234,12 +234,12 @@ class EcmDirectory // extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->fk_parent=trim($this->fk_parent); - $this->description=trim($this->description); + $this->label = trim($this->label); + $this->fk_parent = trim($this->fk_parent); + $this->description = trim($this->description); // Check parameters // Put here code to add control on parameters values @@ -248,28 +248,28 @@ class EcmDirectory // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " fk_parent='".$this->db->escape($this->fk_parent)."',"; - $sql.= " description='".$this->db->escape($this->description)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " fk_parent='".$this->db->escape($this->fk_parent)."',"; + $sql .= " description='".$this->db->escape($this->description)."'"; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MYECMDIR_MODIFY', $user); + $result = $this->call_trigger('MYECMDIR_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -292,15 +292,15 @@ class EcmDirectory // extends CommonObject { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - if (preg_match('/[0-9]+/', $value)) $sql.= " cachenbofdoc = ".(int) $value; - else $sql.= " cachenbofdoc = cachenbofdoc ".$value." 1"; - $sql.= " WHERE rowid = ".$this->id; + if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value; + else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } else @@ -323,20 +323,20 @@ class EcmDirectory // extends CommonObject public function fetch($id) { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.label,"; - $sql.= " t.fk_parent,"; - $sql.= " t.description,"; - $sql.= " t.cachenbofdoc,"; - $sql.= " t.fk_user_c,"; - $sql.= " t.fk_user_m,"; - $sql.= " t.date_c as date_c,"; - $sql.= " t.date_m as date_m"; - $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.label,"; + $sql .= " t.fk_parent,"; + $sql .= " t.description,"; + $sql .= " t.cachenbofdoc,"; + $sql .= " t.fk_user_c,"; + $sql .= " t.fk_user_m,"; + $sql .= " t.date_c as date_c,"; + $sql .= " t.date_m as date_m"; + $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -357,11 +357,11 @@ class EcmDirectory // extends CommonObject $this->db->free($resql); - return $obj?1:0; + return $obj ? 1 : 0; } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -380,29 +380,29 @@ class EcmDirectory // extends CommonObject global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; - if ($mode != 'databaseonly') $relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3 + if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 - dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly')?'':' relativepath='.$relativepath)); + dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath)); $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $this->db->rollback(); - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -2; } else { // Call trigger - $result=$this->call_trigger('MYECMDIR_DELETE', $user); + $result = $this->call_trigger('MYECMDIR_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -413,30 +413,30 @@ class EcmDirectory // extends CommonObject if ($mode != 'databaseonly') { - $file = $conf->ecm->dir_output . "/" . $relativepath; + $file = $conf->ecm->dir_output."/".$relativepath; if ($deletedirrecursive) { - $result=@dol_delete_dir_recursive($file, 0, 0); + $result = @dol_delete_dir_recursive($file, 0, 0); } else { - $result=@dol_delete_dir($file, 0); + $result = @dol_delete_dir($file, 0); } } - if ($result || ! @is_dir(dol_osencode($file))) + if ($result || !@is_dir(dol_osencode($file))) { $this->db->commit(); } else { - $this->error='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); $this->db->rollback(); $error++; } - if (! $error) return 1; + if (!$error) return 1; else return -1; } @@ -450,11 +450,11 @@ class EcmDirectory // extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->label='MyDirectory'; - $this->fk_parent='0'; - $this->description='This is a directory'; + $this->label = 'MyDirectory'; + $this->fk_parent = '0'; + $this->description = 'This is a directory'; } @@ -472,24 +472,24 @@ class EcmDirectory // extends CommonObject { global $langs; - $result=''; + $result = ''; //$newref=str_replace('_',' ',$this->ref); - $newref=$this->ref; - $label=$langs->trans("ShowECMSection").': '.$newref; - $linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + $newref = $this->ref; + $label = $langs->trans("ShowECMSection").': '.$newref; + $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = 'picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($max?dol_trunc($newref, $max, 'middle'):$newref); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); $result .= $linkend; return $result; @@ -505,17 +505,17 @@ class EcmDirectory // extends CommonObject { $this->get_full_arbo($force); - $ret=''; - $idtosearch=$this->id; - $i=0; + $ret = ''; + $idtosearch = $this->id; + $i = 0; do { // Get index cursor in this->cats for id_mere - $cursorindex=-1; + $cursorindex = -1; foreach ($this->cats as $key => $val) { if ($this->cats[$key]['id'] == $idtosearch) { - $cursorindex=$key; + $cursorindex = $key; break; } } @@ -524,13 +524,13 @@ class EcmDirectory // extends CommonObject if ($cursorindex >= 0) { // Path is label sanitized (no space and no special char) and concatenated - $ret=dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; + $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; - $idtosearch=$this->cats[$cursorindex]['id_mere']; + $idtosearch = $this->cats[$cursorindex]['id_mere']; $i++; } } - while ($cursorindex >= 0 && ! empty($idtosearch) && $i < 100); // i avoid infinite loop + while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop return $ret; } @@ -546,22 +546,22 @@ class EcmDirectory // extends CommonObject // phpcs:enable global $conf; - $this->motherof=array(); + $this->motherof = array(); // Load array[child]=parent $sql = "SELECT fk_parent as id_parent, rowid as id_son"; - $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories"; - $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories"; + $sql .= " WHERE fk_parent != 0"; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->motherof[$obj->id_son]=$obj->id_parent; + $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; } @@ -625,7 +625,7 @@ class EcmDirectory // extends CommonObject // phpcs:enable global $conf; - if (empty($force) && ! empty($this->full_arbo_loaded)) + if (empty($force) && !empty($this->full_arbo_loaded)) { return $this->cats; } @@ -635,29 +635,29 @@ class EcmDirectory // extends CommonObject // Charge tableau des categories $sql = "SELECT c.rowid as rowid, c.label as label,"; - $sql.= " c.description as description, c.cachenbofdoc,"; - $sql.= " c.fk_user_c,"; - $sql.= " c.date_c,"; - $sql.= " u.login as login_c,"; - $sql.= " ca.rowid as rowid_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca"; - $sql.= " ON c.rowid = ca.fk_parent"; - $sql.= " WHERE c.fk_user_c = u.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.label, c.rowid"; + $sql .= " c.description as description, c.cachenbofdoc,"; + $sql .= " c.fk_user_c,"; + $sql .= " c.date_c,"; + $sql .= " u.login as login_c,"; + $sql .= " ca.rowid as rowid_fille"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca"; + $sql .= " ON c.rowid = ca.fk_parent"; + $sql .= " WHERE c.fk_user_c = u.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.label, c.rowid"; dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->cats = array(); - $i=0; + $i = 0; // This assignment in condition is not a bug. It allows walking the results. while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; - $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid])?$this->motherof[$obj->rowid]:''); + $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : ''); $this->cats[$obj->rowid]['label'] = $obj->label; $this->cats[$obj->rowid]['description'] = $obj->description; $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc; @@ -665,18 +665,18 @@ class EcmDirectory // extends CommonObject $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; - if (! empty($obj->rowid_fille)) + if (!empty($obj->rowid_fille)) { if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { - $newelempos=count($this->cats[$obj->rowid]['id_children']); + $newelempos = count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements
    "; - $this->cats[$obj->rowid]['id_children'][$newelempos]=$obj->rowid_fille; + $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille; } else { //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau
    "; - $this->cats[$obj->rowid]['id_children']=array($obj->rowid_fille); + $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille); } } $i++; @@ -689,14 +689,14 @@ class EcmDirectory // extends CommonObject } // We add properties fullxxx to all elements - foreach($this->cats as $key => $val) + foreach ($this->cats as $key => $val) { if (isset($motherof[$key])) continue; $this->build_path_from_id_categ($key, 0); } - $this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); - $this->full_arbo_loaded=1; + $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); + $this->full_arbo_loaded = 1; return $this->cats; } @@ -714,30 +714,30 @@ class EcmDirectory // extends CommonObject { // phpcs:enable // Define fullpath - if (! empty($this->cats[$id_categ]['id_mere'])) + if (!empty($this->cats[$id_categ]['id_mere'])) { - $this->cats[$id_categ]['fullpath'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; - $this->cats[$id_categ]['fullpath'].='_'.$id_categ; - $this->cats[$id_categ]['fullrelativename'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; - $this->cats[$id_categ]['fullrelativename'].='/'.$this->cats[$id_categ]['label']; - $this->cats[$id_categ]['fulllabel'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel']; - $this->cats[$id_categ]['fulllabel'].=' >> '.$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; + $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ; + $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; + $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel']; + $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label']; } else { - $this->cats[$id_categ]['fullpath']='_'.$id_categ; - $this->cats[$id_categ]['fullrelativename']=$this->cats[$id_categ]['label']; - $this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fullpath'] = '_'.$id_categ; + $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label']; + $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; } // We count number of _ to have level (we use strlen that is faster than dol_strlen) - $this->cats[$id_categ]['level']=strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath'])); + $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath'])); // Traite ces enfants $protection++; - if ($protection > 20) return; // On ne traite pas plus de 20 niveaux + if ($protection > 20) return; // On ne traite pas plus de 20 niveaux if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { - foreach($this->cats[$id_categ]['id_children'] as $key => $val) + foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { $this->build_path_from_id_categ($val, $protection); } @@ -755,34 +755,34 @@ class EcmDirectory // extends CommonObject global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); - $filelist=dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'); + $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); + $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'); // Test if filelist is in database // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " cachenbofdoc = '".count($filelist)."'"; + $sql .= " cachenbofdoc = '".count($filelist)."'"; if (empty($all)) // By default { - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; } else { - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity = ".$conf->entity; } dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->cachenbofdoc=count($filelist); + $this->cachenbofdoc = count($filelist); return $this->cachenbofdoc; } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -803,19 +803,19 @@ class EcmDirectory // extends CommonObject public function call_trigger($triggerName, $user) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers($triggerName, $this, $user, $langs, $conf); + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { - $this->errors=array_merge($this->errors, $interface->errors); + $this->errors = array_merge($this->errors, $interface->errors); } else { - $this->errors=$interface->errors; + $this->errors = $interface->errors; } } return $result; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 01f6228ad83..0c7c4c4cebb 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -27,7 +27,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage ECM files @@ -60,7 +60,7 @@ class EcmFiles extends CommonObject */ public $label; - public $share; // hash for file sharing, empty by default (example: getRandomPassword(true)) + public $share; // hash for file sharing, empty by default (example: getRandomPassword(true)) /** * @var int Entity @@ -79,7 +79,7 @@ class EcmFiles extends CommonObject public $keywords; public $cover; public $position; - public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' + public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' public $extraparams; public $date_c = ''; public $date_m = ''; @@ -142,7 +142,7 @@ class EcmFiles extends CommonObject } if (isset($this->filepath)) { $this->filepath = trim($this->filepath); - $this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last / + $this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last / } if (isset($this->fullpath_orig)) { $this->fullpath_orig = trim($this->fullpath_orig); @@ -179,20 +179,20 @@ class EcmFiles extends CommonObject // If ref not defined $ref = ''; - if (! empty($this->ref)) + if (!empty($this->ref)) { - $ref=$this->ref; + $ref = $this->ref; } else { include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; $ref = dol_hash($this->filepath.'/'.$this->filename, 3); } - $maxposition=0; + $maxposition = 0; if (empty($this->position)) // Get max used { - $sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; + $sql = "SELECT MAX(position) as maxposition FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; $resql = $this->db->query($sql); if ($resql) @@ -202,14 +202,14 @@ class EcmFiles extends CommonObject } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); + $this->errors[] = 'Error '.$this->db->lasterror(); return --$error; } - $maxposition=$maxposition+1; + $maxposition = $maxposition + 1; } else { - $maxposition=$this->position; + $maxposition = $this->position; } // Check parameters @@ -218,75 +218,75 @@ class EcmFiles extends CommonObject $this->errors[] = 'Bad property filename or filepath'; return --$error; } - if (! isset($this->entity)) + if (!isset($this->entity)) { $this->entity = $conf->entity; } // Put here code to add control on parameters values // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'ref,'; - $sql.= 'label,'; - $sql.= 'share,'; - $sql.= 'entity,'; - $sql.= 'filename,'; - $sql.= 'filepath,'; - $sql.= 'fullpath_orig,'; - $sql.= 'description,'; - $sql.= 'keywords,'; - $sql.= 'cover,'; - $sql.= 'position,'; - $sql.= 'gen_or_uploaded,'; - $sql.= 'extraparams,'; - $sql.= 'date_c,'; - $sql.= 'date_m,'; - $sql.= 'fk_user_c,'; - $sql.= 'fk_user_m,'; - $sql.= 'acl,'; - $sql.= 'src_object_type,'; - $sql.= 'src_object_id'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql .= 'ref,'; + $sql .= 'label,'; + $sql .= 'share,'; + $sql .= 'entity,'; + $sql .= 'filename,'; + $sql .= 'filepath,'; + $sql .= 'fullpath_orig,'; + $sql .= 'description,'; + $sql .= 'keywords,'; + $sql .= 'cover,'; + $sql .= 'position,'; + $sql .= 'gen_or_uploaded,'; + $sql .= 'extraparams,'; + $sql .= 'date_c,'; + $sql .= 'date_m,'; + $sql .= 'fk_user_c,'; + $sql .= 'fk_user_m,'; + $sql .= 'acl,'; + $sql .= 'src_object_type,'; + $sql .= 'src_object_id'; $sql .= ') VALUES ('; $sql .= " '".$ref."', "; - $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; - $sql .= ' '.(! isset($this->share)?'NULL':"'".$this->db->escape($this->share)."'").','; + $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(!isset($this->share) ? 'NULL' : "'".$this->db->escape($this->share)."'").','; $sql .= ' '.$this->entity.','; - $sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").','; - $sql .= ' '.(! isset($this->filepath)?'NULL':"'".$this->db->escape($this->filepath)."'").','; - $sql .= ' '.(! isset($this->fullpath_orig)?'NULL':"'".$this->db->escape($this->fullpath_orig)."'").','; - $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; - $sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").','; - $sql .= ' '.(! isset($this->cover)?'NULL':"'".$this->db->escape($this->cover)."'").','; + $sql .= ' '.(!isset($this->filename) ? 'NULL' : "'".$this->db->escape($this->filename)."'").','; + $sql .= ' '.(!isset($this->filepath) ? 'NULL' : "'".$this->db->escape($this->filepath)."'").','; + $sql .= ' '.(!isset($this->fullpath_orig) ? 'NULL' : "'".$this->db->escape($this->fullpath_orig)."'").','; + $sql .= ' '.(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(!isset($this->keywords) ? 'NULL' : "'".$this->db->escape($this->keywords)."'").','; + $sql .= ' '.(!isset($this->cover) ? 'NULL' : "'".$this->db->escape($this->cover)."'").','; $sql .= ' '.$maxposition.','; - $sql .= ' '.(! isset($this->gen_or_uploaded)?'NULL':"'".$this->db->escape($this->gen_or_uploaded)."'").','; - $sql .= ' '.(! isset($this->extraparams)?'NULL':"'".$this->db->escape($this->extraparams)."'").','; + $sql .= ' '.(!isset($this->gen_or_uploaded) ? 'NULL' : "'".$this->db->escape($this->gen_or_uploaded)."'").','; + $sql .= ' '.(!isset($this->extraparams) ? 'NULL' : "'".$this->db->escape($this->extraparams)."'").','; $sql .= ' '."'".$this->db->idate($this->date_c)."'".','; - $sql .= ' '.(! isset($this->date_m) || dol_strlen($this->date_m)==0?'NULL':"'".$this->db->idate($this->date_m)."'").','; - $sql .= ' '.(! isset($this->fk_user_c)?$user->id:$this->fk_user_c).','; - $sql .= ' '.(! isset($this->fk_user_m)?'NULL':$this->fk_user_m).','; - $sql .= ' '.(! isset($this->acl)?'NULL':"'".$this->db->escape($this->acl)."'").','; - $sql .= ' '.(! isset($this->src_object_type)?'NULL':"'".$this->db->escape($this->src_object_type)."'").','; - $sql .= ' '.(! isset($this->src_object_id)?'NULL':$this->src_object_id); + $sql .= ' '.(!isset($this->date_m) || dol_strlen($this->date_m) == 0 ? 'NULL' : "'".$this->db->idate($this->date_m)."'").','; + $sql .= ' '.(!isset($this->fk_user_c) ? $user->id : $this->fk_user_c).','; + $sql .= ' '.(!isset($this->fk_user_m) ? 'NULL' : $this->fk_user_m).','; + $sql .= ' '.(!isset($this->acl) ? 'NULL' : "'".$this->db->escape($this->acl)."'").','; + $sql .= ' '.(!isset($this->src_object_type) ? 'NULL' : "'".$this->db->escape($this->src_object_type)."'").','; + $sql .= ' '.(!isset($this->src_object_id) ? 'NULL' : $this->src_object_id); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->position = $maxposition; // Triggers - if (! $notrigger) + if (!$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -296,7 +296,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -344,25 +344,25 @@ class EcmFiles extends CommonObject $sql .= " t.acl,"; $sql .= " t.src_object_type,"; $sql .= " t.src_object_id"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - $sql.= ' WHERE 1 = 1'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if ($relativepath) { - $sql .= " AND t.filepath = '" . $this->db->escape(dirname($relativepath)) . "' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.filepath = '".$this->db->escape(dirname($relativepath))."' AND t.filename = '".$this->db->escape(basename($relativepath))."'"; + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($ref)) { // hash of file path + elseif (!empty($ref)) { // hash of file path $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($hashoffile)) { // hash of content + elseif (!empty($hashoffile)) { // hash of content $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index } - elseif (! empty($hashforshare)) { + elseif (!empty($hashforshare)) { $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'"; //$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique } @@ -373,10 +373,10 @@ class EcmFiles extends CommonObject $sql .= " AND t.entity = ".$conf->entity; } else { - $sql .= ' AND t.rowid = '.$this->db->escape($id); // rowid already unique + $sql .= ' AND t.rowid = '.$this->db->escape($id); // rowid already unique } - $this->db->plimit(1); // When we search on src or on hash of content (hashforfile) to solve hash conflict when several files has same content, we take first one only + $this->db->plimit(1); // When we search on src or on hash of content (hashforfile) to solve hash conflict when several files has same content, we take first one only $this->db->order('t.rowid', 'ASC'); $resql = $this->db->query($sql); @@ -422,8 +422,8 @@ class EcmFiles extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); return -1; } @@ -466,28 +466,28 @@ class EcmFiles extends CommonObject $sql .= " t.acl,"; $sql .= " t.src_object_type,"; $sql .= " t.src_object_id"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } - $sql.= ' WHERE 1 = 1'; + $sql .= ' WHERE 1 = 1'; /* Fetching this table depends on filepath+filename, it must not depends on entity if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")"; }*/ if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $this->lines = array(); @@ -526,10 +526,10 @@ class EcmFiles extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -601,42 +601,42 @@ class EcmFiles extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= " ref = '".dol_hash($this->filepath.'/'.$this->filename, 3)."',"; - $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; - $sql .= ' share = '.(! empty($this->share)?"'".$this->db->escape($this->share)."'":"null").','; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).','; - $sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").','; - $sql .= ' filepath = '.(isset($this->filepath)?"'".$this->db->escape($this->filepath)."'":"null").','; - $sql .= ' fullpath_orig = '.(isset($this->fullpath_orig)?"'".$this->db->escape($this->fullpath_orig)."'":"null").','; - $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; - $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").','; - $sql .= ' cover = '.(isset($this->cover)?"'".$this->db->escape($this->cover)."'":"null").','; - $sql .= ' position = '.(isset($this->position)?$this->db->escape($this->position):"0").','; - $sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded)?"'".$this->db->escape($this->gen_or_uploaded)."'":"null").','; - $sql .= ' extraparams = '.(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").','; - $sql .= ' date_c = '.(! isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').','; + $sql .= ' label = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; + $sql .= ' share = '.(!empty($this->share) ? "'".$this->db->escape($this->share)."'" : "null").','; + $sql .= ' entity = '.(isset($this->entity) ? $this->entity : $conf->entity).','; + $sql .= ' filename = '.(isset($this->filename) ? "'".$this->db->escape($this->filename)."'" : "null").','; + $sql .= ' filepath = '.(isset($this->filepath) ? "'".$this->db->escape($this->filepath)."'" : "null").','; + $sql .= ' fullpath_orig = '.(isset($this->fullpath_orig) ? "'".$this->db->escape($this->fullpath_orig)."'" : "null").','; + $sql .= ' description = '.(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").','; + $sql .= ' keywords = '.(isset($this->keywords) ? "'".$this->db->escape($this->keywords)."'" : "null").','; + $sql .= ' cover = '.(isset($this->cover) ? "'".$this->db->escape($this->cover)."'" : "null").','; + $sql .= ' position = '.(isset($this->position) ? $this->db->escape($this->position) : "0").','; + $sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded) ? "'".$this->db->escape($this->gen_or_uploaded)."'" : "null").','; + $sql .= ' extraparams = '.(isset($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").','; + $sql .= ' date_c = '.(!isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').','; //$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').','; // Field automatically updated - $sql .= ' fk_user_m = '.($this->fk_user_m > 0?$this->fk_user_m:$user->id).','; - $sql .= ' acl = '.(isset($this->acl)?"'".$this->db->escape($this->acl)."'":"null").','; - $sql .= ' src_object_id = '.($this->src_object_id > 0?$this->src_object_id:"null").','; - $sql .= ' src_object_type = '.(isset($this->src_object_type)?"'".$this->db->escape($this->src_object_type)."'":"null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql .= ' fk_user_m = '.($this->fk_user_m > 0 ? $this->fk_user_m : $user->id).','; + $sql .= ' acl = '.(isset($this->acl) ? "'".$this->db->escape($this->acl)."'" : "null").','; + $sql .= ' src_object_id = '.($this->src_object_id > 0 ? $this->src_object_id : "null").','; + $sql .= ' src_object_type = '.(isset($this->src_object_type) ? "'".$this->db->escape($this->src_object_type)."'" : "null"); + $sql .= ' WHERE rowid='.$this->id; $this->db->begin(); $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } // Triggers - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -645,7 +645,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -670,10 +670,10 @@ class EcmFiles extends CommonObject $this->db->begin(); // Triggers - if (! $notrigger) + if (!$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); + $result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -681,14 +681,14 @@ class EcmFiles extends CommonObject // If you need to delete child tables to, you can insert them here if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } } @@ -696,7 +696,7 @@ class EcmFiles extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -734,9 +734,9 @@ class EcmFiles extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); @@ -749,7 +749,7 @@ class EcmFiles extends CommonObject } else { $this->db->rollback(); - return - 1; + return -1; } } @@ -769,40 +769,40 @@ class EcmFiles extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("MyModule") . ''; - $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MyModule").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowProject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = '
    '; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($withpicto) { - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; + $result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); + if ($withpicto != 2) $result .= ' '; } - $result.= $linkstart . $this->ref . $linkend; + $result .= $linkstart.$this->ref.$linkend; return $result; } @@ -841,7 +841,7 @@ class EcmFiles extends CommonObject */ public function initAsSpecimen() { - global $conf,$user; + global $conf, $user; $this->id = 0; @@ -891,7 +891,7 @@ class EcmfilesLine public $keywords; public $cover; public $position; - public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' + public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown' public $extraparams; public $date_c = ''; public $date_m = ''; diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 92cee2570bc..de9f289eb79 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -35,7 +35,7 @@ class FormEcm /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -62,9 +62,9 @@ class FormEcm global $conf, $langs; $langs->load("ecm"); - if ($select_name=='') $select_name="catParent"; + if ($select_name == '') $select_name = "catParent"; - $cate_arbo=null; + $cate_arbo = null; if ($module == 'ecm') { $cat = new EcmDirectory($this->db); @@ -74,17 +74,17 @@ class FormEcm { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $path = $conf->medias->multidir_output[$conf->entity]; - $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$','^\.'), 'relativename', SORT_ASC); + $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } $output = ''; - $output.=ajax_combobox($select_name); - $output.= "\n"; + $output .= ''; + $output .= ajax_combobox($select_name); + $output .= "\n"; return $output; } } diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index 979d4cf2709..0c9190b9a4c 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts","categories")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts", "categories")); // Get parameters $socid = GETPOST('socid', 'int'); @@ -41,7 +41,7 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module='ecm'; +if (empty($module)) $module = 'ecm'; // Security check if ($user->socid > 0) @@ -50,8 +50,8 @@ if ($user->socid > 0) $socid = $user->socid; } -$section=$urlsection=GETPOST('section', 'alpha'); -if (empty($urlsection)) $urlsection='misc'; +$section = $urlsection = GETPOST('section', 'alpha'); +if (empty($urlsection)) $urlsection = 'misc'; if ($module == 'ecm') { @@ -69,14 +69,14 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="label"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "label"; $ecmdir = new EcmDirectory($db); -if (! empty($section)) +if (!empty($section)) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; @@ -97,7 +97,7 @@ if ($module == 'medias') $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); } -if (! $permtoadd) accessforbidden(); +if (!$permtoadd) accessforbidden(); @@ -110,14 +110,14 @@ if ($action == 'add' && $permtoadd) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { - header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module?'&module='.$module:'')); + header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module ? '&module='.$module : '')); exit; } } @@ -125,10 +125,10 @@ if ($action == 'add' && $permtoadd) $ref = trim(GETPOST("ref", 'alpha')); $label = trim(GETPOST("label", 'alpha')); $desc = trim(GETPOST("desc", 'alpha')); - $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) - if ($catParent == '-1') $catParent=0; + $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) + if ($catParent == '-1') $catParent = 0; - $error=0; + $error = 0; if (empty($label)) { @@ -137,7 +137,7 @@ if ($action == 'add' && $permtoadd) $error++; } - if (! $error) + if (!$error) { if ($module == 'ecm') { @@ -168,9 +168,9 @@ if ($action == 'add' && $permtoadd) dol_print_error('', 'Bad value for module. Not supported.'); } - if (! $error) + if (!$error) { - $fullpathofdir = $dirfornewdir.'/'.($catParent? $catParent.'/' : '').$label; + $fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label; $result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT); if ($result < 0) { @@ -185,9 +185,9 @@ if ($action == 'add' && $permtoadd) } } - if (! $error) + if (!$error) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -203,7 +203,7 @@ if ($action == 'add' && $permtoadd) // Deleting file elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } @@ -216,8 +216,8 @@ elseif ($action == 'confirm_deletesection' && $confirm == 'yes') llxHeader('', $langs->trans("ECMNewSection")); -$form=new Form($db); -$formecm=new FormEcm($db); +$form = new Form($db); +$formecm = new FormEcm($db); if ($action == 'create') { @@ -232,7 +232,7 @@ if ($action == 'create') if ($website) print ''; if ($pageid) print ''; - $title=$langs->trans("ECMNewSection"); + $title = $langs->trans("ECMNewSection"); print load_fiche_titre($title); dol_fiche_head(); diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 3793be8a784..42c6b140f3c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module='ecm'; +if (empty($module)) $module = 'ecm'; // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -49,11 +49,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $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"; -$section=GETPOST("section", 'alpha')?GETPOST("section", 'alpha'):GETPOST("relativedir", 'alpha'); -if (! $section) +$section = GETPOST("section", 'alpha') ?GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha'); +if (!$section) { dol_print_error('', "ErrorSectionParamNotDefined"); exit; @@ -64,14 +64,14 @@ $ecmdir = new EcmDirectory($db); if ($module == 'ecm') { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } else // For example $module == 'medias' @@ -101,14 +101,14 @@ if ($module == 'medias') */ // Upload file -if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { if (dol_mkdir($upload_dir) >= 0) { - $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); + $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $result=$ecmdir->changeNbOfFiles('+'); + $result = $ecmdir->changeNbOfFiles('+'); } else { @@ -138,12 +138,12 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'confirm_deletefile' && $confirm == 'yes') { $langs->load("other"); - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file); + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); } // Remove dir @@ -160,7 +160,7 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') if ($module == 'ecm') { // Fetch was already done - $result=$ecmdir->delete($user, 'all', $deletedirrecursive); + $result = $ecmdir->delete($user, 'all', $deletedirrecursive); if ($result <= 0) { $langs->load('errors'); @@ -193,20 +193,20 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') } // Update dirname or description -if ($action == 'update' && ! GETPOST('cancel', 'alpha')) +if ($action == 'update' && !GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; if ($module == 'ecm') { - $oldlabel=$ecmdir->label; - $olddir=$ecmdir->getRelativePath(0); - $olddir=$conf->ecm->dir_output.'/'.$olddir; + $oldlabel = $ecmdir->label; + $olddir = $ecmdir->getRelativePath(0); + $olddir = $conf->ecm->dir_output.'/'.$olddir; } else { - $olddir=GETPOST('section', 'alpha'); - $olddir=$conf->medias->multidir_output[$conf->entity].'/'.$relativepath; + $olddir = GETPOST('section', 'alpha'); + $olddir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; } if ($module == 'ecm') @@ -216,17 +216,17 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) // Fetch was already done $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); $ecmdir->description = GETPOST("description"); - $result=$ecmdir->update($user); + $result = $ecmdir->update($user); if ($result > 0) { // Try to rename file if changed - if ($oldlabel != $ecmdir->label && file_exists($olddir)) + if ($oldlabel != $ecmdir->label && file_exists($olddir)) { - $newdir=$ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory - $newdir=$conf->ecm->dir_output.'/'.$newdir; + $newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory + $newdir = $conf->ecm->dir_output.'/'.$newdir; //print $olddir.'-'.$newdir; - $result=@rename($olddir, $newdir); - if (! $result) + $result = @rename($olddir, $newdir); + if (!$result) { $langs->load('errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); @@ -234,12 +234,12 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) } } - if (! $error) + if (!$error) { $db->commit(); // Set new value after renaming - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; } else @@ -257,18 +257,18 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) { $newdir = $conf->medias->multidir_output[$conf->entity].'/'.GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); - $result=@rename($olddir, $newdir); - if (! $result) + $result = @rename($olddir, $newdir); + if (!$result) { $langs->load('errors'); setEventMessages($langs->trans('ErrorFailToRenameDir', $olddir, $newdir), null, 'errors'); $error++; } - if (! $error) + if (!$error) { // Set new value after renaming - $relativepath=GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); + $relativepath = GETPOST('oldrelparentdir', 'alpha').'/'.GETPOST('label', 'alpha'); $upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; $section = $relativepath; } @@ -281,9 +281,9 @@ if ($action == 'update' && ! GETPOST('cancel', 'alpha')) * View ********************************************************************/ -$form=new Form($db); +$form = new Form($db); -$object=new EcmDirectory($db); // Need to create a new one instance +$object = new EcmDirectory($db); // Need to create a new one instance if ($module == 'ecm') { @@ -293,12 +293,12 @@ if ($module == 'ecm') llxHeader(); // Built the file List -$filearrayall=dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); -$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); -$totalsize=0; -foreach($filearray as $key => $file) +$filearrayall = dol_dir_list($upload_dir, "all", 0, '', '', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); +$totalsize = 0; +foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } @@ -316,33 +316,33 @@ if ($action == 'edit') } -$morehtml=''; +$morehtml = ''; $morehtmlref = '/'.$module.'/'.$relativepath; if ($module == 'ecm') { - $s=''; + $s = ''; $result = 1; - $i=0; - $tmpecmdir=new EcmDirectory($db); // Need to create a new one + $i = 0; + $tmpecmdir = new EcmDirectory($db); // Need to create a new one $tmpecmdir->fetch($ecmdir->id); while ($tmpecmdir && $result > 0) { - $tmpecmdir->ref=$tmpecmdir->label; + $tmpecmdir->ref = $tmpecmdir->label; if ($i == 0 && $action == 'edit') { - $s=''; + $s = ''; } - else $s=$tmpecmdir->getNomUrl(1).$s; + else $s = $tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) { - $s=' -> '.$s; - $result=$tmpecmdir->fetch($tmpecmdir->fk_parent); + $s = ' -> '.$s; + $result = $tmpecmdir->fetch($tmpecmdir->fk_parent); } else { - $tmpecmdir=0; + $tmpecmdir = 0; } $i++; } @@ -351,25 +351,25 @@ if ($module == 'ecm') } if ($module == 'medias') { - $s='medias -> '; + $s = 'medias -> '; $result = 1; - $subdirs=explode('/', $section); - $i=0; - foreach($subdirs as $subdir) + $subdirs = explode('/', $section); + $i = 0; + foreach ($subdirs as $subdir) { if ($i == (count($subdirs) - 1)) { if ($action == 'edit') { - $s.=''; - $s.=''; - $s.=''; + $s .= ''; + $s .= ''; + $s .= ''; } - else $s.=$subdir; + else $s .= $subdir; } if ($i < (count($subdirs) - 1)) { - $s.=$subdir.' -> '; + $s .= $subdir.' -> '; } $i++; } @@ -401,7 +401,7 @@ if ($module == 'ecm') print ''; print ''.$langs->trans("ECMCreationUser").''; - $userecm=new User($db); + $userecm = new User($db); $userecm->fetch($ecmdir->fk_user_c); print $userecm->getNomUrl(1); print ''; @@ -428,7 +428,7 @@ else } print ''; print ''.$langs->trans("ECMNbOfDocs").''; -$nbofiles=count($filearray); +$nbofiles = count($filearray); print $nbofiles; if ($ecmdir->id > 0) { @@ -470,12 +470,12 @@ if ($action != 'edit' && $action != 'delete') if ($permtoadd) { - print ''.$langs->trans('Edit').''; + print ''.$langs->trans('Edit').''; } if ($permtoadd) { - print ''.$langs->trans('ECMAddSection').''; + print ''.$langs->trans('ECMAddSection').''; } else { @@ -486,7 +486,7 @@ if ($action != 'edit' && $action != 'delete') //{ if ($permtoadd) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { @@ -512,18 +512,18 @@ if ($action == 'delete') // Confirm remove file if ($action == 'delete_dir') { - $relativepathwithoutslash=preg_replace('/[\/]$/', '', $relativepath); + $relativepathwithoutslash = preg_replace('/[\/]$/', '', $relativepath); //Form to close proposal (signed or not) if (count($filearrayall) > 0) { $langs->load("other"); $formquestion = array( - array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
    '.$langs->trans("DeleteAlsoContentRecursively"),'value' => '0') // Field to complete private note (not replace) + array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
    '.$langs->trans("DeleteAlsoContentRecursively"), 'value' => '0') // Field to complete private note (not replace) ); } - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section', 'alpha').($module?'&module='.$module:'').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section', 'alpha').($module ? '&module='.$module : '').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); } diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index e88417c526a..9e51da09899 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -32,18 +32,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ecm', 0); // Get parameters -$socid=GETPOST('socid', 'int'); -$action=GETPOST('action', 'aZ09'); -$section=GETPOST('section', 'int')?GETPOST('section', 'int'):GETPOST('section_id', 'int'); -if (! $section) $section=0; -$section_dir=GETPOST('section_dir', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); +$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); +if (!$section) $section = 0; +$section_dir = GETPOST('section_dir', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -52,25 +52,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 (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="fullname"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "fullname"; $ecmdir = new EcmDirectory($db); if ($section) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } } -$form=new Form($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); $userstatic = new User($db); -$error=0; +$error = 0; /* @@ -82,23 +82,23 @@ $error=0; //include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // Upload file (code similar but different than actions_linkedfiles.inc.php) -if (GETPOST("sendit", 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST("sendit", 'none') && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Define relativepath and upload_dir - $relativepath=''; - if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath(); - else $relativepath=$section_dir; + $relativepath = ''; + if ($ecmdir->id) $relativepath = $ecmdir->getRelativePath(); + else $relativepath = $section_dir; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; - else $userfiles=array($_FILES['userfile']['tmp_name']); + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; + else $userfiles = array($_FILES['userfile']['tmp_name']); - foreach($userfiles as $key => $userfile) + foreach ($userfiles as $key => $userfile) { if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); } else { @@ -107,13 +107,13 @@ if (GETPOST("sendit", 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } - if (! $error) + if (!$error) { $generatethumbs = 0; $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { - $result=$ecmdir->changeNbOfFiles('+'); + $result = $ecmdir->changeNbOfFiles('+'); } } } @@ -126,14 +126,14 @@ if ($action == 'confirm_deletefile') // GETPOST('urlfile','alpha') is full relative URL from ecm root dir. Contains path of all sections. //var_dump(GETPOST('urlfile'));exit; - $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:''); - $file = $upload_dir . "/" . GETPOST('urlfile', 'alpha'); + $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); + $file = $upload_dir."/".GETPOST('urlfile', 'alpha'); - $ret=dol_delete_file($file); // This include also the delete from file index in database. + $ret = dol_delete_file($file); // This include also the delete from file index in database. if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); } else { @@ -142,7 +142,7 @@ if ($action == 'confirm_deletefile') clearstatcache(); } - $action='file_manager'; + $action = 'file_manager'; } // Add directory @@ -170,7 +170,7 @@ if ($action == 'add' && $user->rights->ecm->setup) // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); clearstatcache(); @@ -186,56 +186,56 @@ if ($action == 'refreshmanual') // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); //print $txt."
    \n"; // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -243,7 +243,7 @@ if ($action == 'refreshmanual') { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -255,7 +255,7 @@ if ($action == 'refreshmanual') else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -265,20 +265,20 @@ if ($action == 'refreshmanual') $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $ecmdirtmp->cachenbofdoc."
    \n";exit; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -286,7 +286,7 @@ if ($action == 'refreshmanual') } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -294,24 +294,24 @@ if ($action == 'refreshmanual') } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree=null; + if ($adirwascreated) $sqltree = null; } @@ -322,18 +322,18 @@ if ($action == 'refreshmanual') // Define height of file area (depends on $_SESSION["dol_screenheight"]) //print $_SESSION["dol_screenheight"]; -$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index_auto.php file +$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index_auto.php file -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; //$morejs=array(); -$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.=''."\n"; +$moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); @@ -342,7 +342,7 @@ dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECM // Add filemanager component -$module='ecm'; +$module = 'ecm'; include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; // End of page diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index be3cc7a372c..6c245e3ad1c 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -31,21 +31,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts")); +$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts")); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ecm', 0); // Get parameters -$socid=GETPOST('socid', 'int'); -$action=GETPOST('action', 'aZ09'); -$section=GETPOST('section', 'int')?GETPOST('section', 'int'):GETPOST('section_id', 'int'); -$module=GETPOST('module', 'alpha'); -if (! $section) $section=0; -$section_dir=GETPOST('section_dir', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); +$section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int'); +$module = GETPOST('module', 'alpha'); +if (!$section) $section = 0; +$section_dir = GETPOST('section_dir', 'alpha'); -$search_doc_ref=GETPOST('search_doc_ref', 'alpha'); +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -54,26 +54,26 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="fullname"; -if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield="level1name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "fullname"; +if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield = "level1name"; $ecmdir = new EcmDirectory($db); if ($section) { - $result=$ecmdir->fetch($section); - if (! $result > 0) + $result = $ecmdir->fetch($section); + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } } -$form=new Form($db); +$form = new Form($db); $ecmdirstatic = new EcmDirectory($db); $userstatic = new User($db); -$error=0; +$error = 0; /* @@ -83,7 +83,7 @@ $error=0; // 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 { - $search_doc_ref=''; + $search_doc_ref = ''; } @@ -119,33 +119,33 @@ if ($action == 'confirm_deletefile') $langs->load("other"); if ($section) { - $result=$ecmdir->fetch($section); - if (! ($result > 0)) + $result = $ecmdir->fetch($section); + if (!($result > 0)) { dol_print_error($db, $ecmdir->error); exit; } - $relativepath=$ecmdir->getRelativePath(); + $relativepath = $ecmdir->getRelativePath(); } - else $relativepath=''; - $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:''); - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). + else $relativepath = ''; + $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : ''); + $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP). - $ret=dol_delete_file($file); + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $result=$ecmdir->changeNbOfFiles('-'); + $result = $ecmdir->changeNbOfFiles('-'); clearstatcache(); } - $action='file_manager'; + $action = 'file_manager'; } // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') { - $result=$ecmdir->delete($user); + $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); clearstatcache(); @@ -161,56 +161,56 @@ if ($action == 'refreshmanual') // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate clearstatcache(); - $diroutputslash=str_replace('\\', '/', $conf->ecm->dir_output); - $diroutputslash.='/'; + $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output); + $diroutputslash .= '/'; // Scan directory tree on disk - $disktree=dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); + $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0); // Scan directory tree in database - $sqltree=$ecmdirstatic->get_full_arbo(0); + $sqltree = $ecmdirstatic->get_full_arbo(0); - $adirwascreated=0; + $adirwascreated = 0; // Now we compare both trees to complete missing trees into database //var_dump($disktree); //var_dump($sqltree); - foreach($disktree as $dirdesc) // Loop on tree onto disk + foreach ($disktree as $dirdesc) // Loop on tree onto disk { - $dirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $dirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) { - $dirisindatabase=1; + $dirisindatabase = 1; break; } } - if (! $dirisindatabase) + if (!$dirisindatabase) { - $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; + $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; dol_syslog($txt); //print $txt."
    \n"; // We must first find the fk_parent of directory to create $dirdesc['fullname'] - $fk_parent=-1; - $relativepathmissing=str_replace($diroutputslash, '', $dirdesc['fullname']); - $relativepathtosearchparent=$relativepathmissing; + $fk_parent = -1; + $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']); + $relativepathtosearchparent = $relativepathmissing; //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent); if (preg_match('/\//', $relativepathtosearchparent)) //while (preg_match('/\//',$relativepathtosearchparent)) { - $relativepathtosearchparent=preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); - $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; + $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent); + $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?"; dol_syslog($txt); //print $txt." -> "; - $parentdirisindatabase=0; - foreach($sqltree as $dirsqldesc) + $parentdirisindatabase = 0; + foreach ($sqltree as $dirsqldesc) { if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) { - $parentdirisindatabase=$dirsqldesc['id']; + $parentdirisindatabase = $dirsqldesc['id']; break; } } @@ -218,7 +218,7 @@ if ($action == 'refreshmanual') { dol_syslog("Yes with id ".$parentdirisindatabase); //print "Yes with id ".$parentdirisindatabase."
    \n"; - $fk_parent=$parentdirisindatabase; + $fk_parent = $parentdirisindatabase; //break; // We found parent, we can stop the while loop } else @@ -230,7 +230,7 @@ if ($action == 'refreshmanual') else { dol_syslog("Parent is root"); - $fk_parent=0; // Parent is root + $fk_parent = 0; // Parent is root } if ($fk_parent >= 0) @@ -240,20 +240,20 @@ if ($action == 'refreshmanual') $ecmdirtmp->description = ''; $ecmdirtmp->fk_parent = $fk_parent; - $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; + $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent; dol_syslog($txt); //print $ecmdirtmp->cachenbofdoc."
    \n";exit; $id = $ecmdirtmp->create($user); if ($id > 0) { - $newdirsql=array('id'=>$id, + $newdirsql = array('id'=>$id, 'id_mere'=>$ecmdirtmp->fk_parent, 'label'=>$ecmdirtmp->label, 'description'=>$ecmdirtmp->description, 'fullrelativename'=>$relativepathmissing); - $sqltree[]=$newdirsql; // We complete fulltree for following loops + $sqltree[] = $newdirsql; // We complete fulltree for following loops //var_dump($sqltree); - $adirwascreated=1; + $adirwascreated = 1; } else { @@ -261,7 +261,7 @@ if ($action == 'refreshmanual') } } else { - $txt="Parent of ".$dirdesc['fullname']." not found"; + $txt = "Parent of ".$dirdesc['fullname']." not found"; dol_syslog($txt); //print $txt."
    \n"; } @@ -269,24 +269,24 @@ if ($action == 'refreshmanual') } // Loop now on each sql tree to check if dir exists - foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + foreach ($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk { - $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; - if (! dol_is_dir($dirtotest)) + $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + if (!dol_is_dir($dirtotest)) { - $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->delete($user, 'databaseonly'); //exit; } } - $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean // it to be sure that fulltree array is not used without reloading it. - if ($adirwascreated) $sqltree=null; + if ($adirwascreated) $sqltree = null; } @@ -297,43 +297,43 @@ if ($action == 'refreshmanual') // Define height of file area (depends on $_SESSION["dol_screenheight"]) //print $_SESSION["dol_screenheight"]; -$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index.php file +$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index.php file -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; //$morejs=array(); -$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.=''."\n"; +$moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); // Add sections to manage -$rowspan=0; -$sectionauto=array(); -if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) +$rowspan = 0; +$sectionauto = array(); +if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } - if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } - if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } - if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } - if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } - if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } - if (! empty($conf->supplier_proposal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBySupplierProposals")); } - if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } - if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } - if (! empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } - if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } - if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } - if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } - if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } - if (! empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } - $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } + if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } + if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); } + if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } + if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->supplier_proposal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBySupplierProposals")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } + if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } + if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); } + if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } + if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } + if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } + if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } + $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); } $head = ecm_prepare_dasboard_head(''); @@ -358,7 +358,7 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax)) print '
    '; // Toolbar -$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); +$url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); print ''; print ''; print ''; @@ -391,28 +391,28 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act print ' '.$langs->trans("ECMSections"); print ''; - $showonrightsize=''; + $showonrightsize = ''; // Auto section if (count($sectionauto)) { - $htmltooltip=$langs->trans("ECMAreaDesc2"); + $htmltooltip = $langs->trans("ECMAreaDesc2"); - $sectionauto=dol_sort_array($sectionauto, 'label', 'ASC', true, false); + $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false); print ''; print ''; print '