diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 10a65cab2fe..56d60281078 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -24,12 +24,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 . '/accountancy/class/accountingaccount.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.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy","salaries")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -37,7 +37,7 @@ $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $massaction = GETPOST('massaction', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'accountingaccountlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search $search_account = GETPOST('search_account', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -58,10 +58,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield = "aa.account_number"; -if (! $sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "aa.account_number"; +if (!$sortorder) $sortorder = "ASC"; -$arrayfields=array( +$arrayfields = array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), @@ -78,27 +78,27 @@ $accounting = new AccountingAccount($db); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha')) { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - if (! empty($cancel)) $action = ''; + if (!empty($cancel)) $action = ''; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { $search_account = ""; $search_label = ""; $search_accountparent = ""; $search_pcgtype = ""; $search_pcgsubtype = ""; - $search_array_options=array(); + $search_array_options = array(); } if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax))) @@ -108,8 +108,8 @@ if (empty($reshook)) if ($chartofaccounts > 0) { // Get language code for this $chartofaccounts - $sql ='SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; - $sql.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; + $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; + $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; $resql = $db->query($sql); if ($resql) { @@ -132,7 +132,7 @@ if (empty($reshook)) { $offsetforchartofaccount += $reg[1]; } - $offsetforchartofaccount+=($conf->entity * 100000000); + $offsetforchartofaccount += ($conf->entity * 100000000); $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); @@ -146,7 +146,7 @@ if (empty($reshook)) } } - if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error++; } } else { @@ -179,12 +179,12 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("ListAccounts")); if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -192,11 +192,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity; -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity; -$sql .= " WHERE asy.rowid = " . $pcgver; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +$sql .= " WHERE asy.rowid = ".$pcgver; //print $sql; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); @@ -220,24 +220,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); -dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); +dol_syslog('accountancy/admin/account.php:: $sql='.$sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_account) $param.= '&search_account='.urlencode($search_account); - if ($search_label) $param.= '&search_label='.urlencode($search_label); - if ($search_accountparent) $param.= '&search_accountparent='.urlencode($search_accountparent); - if ($search_pcgtype) $param.= '&search_pcgtype='.urlencode($search_pcgtype); - if ($search_pcgsubtype) $param.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_account) $param .= '&search_account='.urlencode($search_account); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent); + if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); + if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ' '; } - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -266,17 +266,17 @@ if ($resql) print ''; print ''; - $newcardbutton.= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); // Box to select active chart of account - print $langs->trans("Selectchartofaccounts") . " : "; + print $langs->trans("Selectchartofaccounts")." : "; print ''; - if (! empty($arrayfields['aa.label']['checked'])) print ''; - if (! empty($arrayfields['aa.account_parent']['checked'])) print ''; - if (! empty($arrayfields['aa.pcg_type']['checked'])) print ''; - if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; - if (! empty($arrayfields['aa.active']['checked'])) print ' '; + if (!empty($arrayfields['aa.account_number']['checked'])) print ''; + if (!empty($arrayfields['aa.label']['checked'])) print ''; + if (!empty($arrayfields['aa.account_parent']['checked'])) print ''; + if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; + if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; + if (!empty($arrayfields['aa.active']['checked'])) print ' '; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print ''; print ''; print ''; - if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $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 (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); - if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $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 (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); + 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"; $accountstatic = new AccountingAccount($db); $accountparent = new AccountingAccount($db); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -351,27 +351,27 @@ if ($resql) print ''; // Account number - if (! empty($arrayfields['aa.account_number']['checked'])) + if (!empty($arrayfields['aa.account_number']['checked'])) { print ""; print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account label - if (! empty($arrayfields['aa.label']['checked'])) + if (!empty($arrayfields['aa.label']['checked'])) { print ""; print $obj->label; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account parent - if (! empty($arrayfields['aa.account_parent']['checked'])) + if (!empty($arrayfields['aa.account_parent']['checked'])) { - if (! empty($obj->account_parent)) + if (!empty($obj->account_parent)) { $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; @@ -380,63 +380,63 @@ if ($resql) print ""; print $accountparent->getNomUrl(1); print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } else { print ' '; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } } // Chart of accounts type - if (! empty($arrayfields['aa.pcg_type']['checked'])) + if (!empty($arrayfields['aa.pcg_type']['checked'])) { print ""; print $obj->pcg_type; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Chart of accounts subtype - if (! empty($arrayfields['aa.pcg_subtype']['checked'])) + if (!empty($arrayfields['aa.pcg_subtype']['checked'])) { print ""; print $obj->pcg_subtype; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Activated or not - if (! empty($arrayfields['aa.active']['checked'])) + if (!empty($arrayfields['aa.active']['checked'])) { print ''; if (empty($obj->active)) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action print ''; if ($user->rights->accounting->chartofaccount) { - print ''; + print ''; print img_edit(); print ''; print ' '; - print ''; + print ''; print img_delete(); print ''; } - print '' . "\n"; - if (! $i) $totalarray['nbfield']++; + print ''."\n"; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index dcc2e608f0b..58a7d9a9d5e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -29,11 +29,11 @@ */ 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/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); // Security access if (empty($user->rights->accounting->chartofaccount)) @@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_* and others -$list = array ( +$list = array( 'ACCOUNTING_LENGTH_GACCOUNT', - 'ACCOUNTING_LENGTH_AACCOUNT' , + 'ACCOUNTING_LENGTH_AACCOUNT', // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { $error = 0; - if (! $error) + if (!$error) { foreach ($list as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error++; } } @@ -77,7 +77,7 @@ if ($action == 'update') { } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -146,9 +146,9 @@ if ($action == 'setenabledraftexport') { if ($action == 'setenablesubsidiarylist') { $setenablesubsidiarylist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - if (! $error) { + if (!$res > 0) + $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -159,15 +159,15 @@ if ($action == 'setenablesubsidiarylist') { * View */ -$title= $langs->trans('ConfigAccountingExpert'); +$title = $langs->trans('ConfigAccountingExpert'); llxHeader('', $title); -$linkback=''; +$linkback = ''; //$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); -print ''; -print ''; +print ''; +print ''; print ''; // Default mode for calculating turnover (parameter ACCOUNTING_MODE) @@ -204,85 +204,85 @@ print '
'; print ''; print ''; -print ''; +print ''; print "\n"; -if (! empty($user->admin)) +if (!empty($user->admin)) { // TO DO Mutualize code for yes/no constants print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; + if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { - print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; + if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; } else { - print ''; } print ''; print ''; - print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + print ''; } else { - print ''; } @@ -295,14 +295,14 @@ foreach ($list as $key) { print ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; // Param $label = $langs->trans($key); print ''; // Value print ''; print ''; @@ -311,7 +311,7 @@ foreach ($list as $key) print '
' . $langs->trans('OtherOptions') . ''.$langs->trans('OtherOptions').'
' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . ''; + print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . ''; + print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . ''; + print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; + print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; + print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
'.$label.''; - print ''; + print ''; print '
'; -print '
'; +print '
'; print '
'; print '
'; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 7d48790348d..02174ea2524 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -28,12 +28,12 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); if (GETPOST("exportcsv", 'alpha')) $action = 'export_csv'; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -75,18 +75,18 @@ $formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); -if (empty($search_date_start) && ! GETPOSTISSET('formfilteraction')) +if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { - $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) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); $search_date_end = strtotime($fiscalYear->date_end); } else { - $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -105,26 +105,26 @@ if ($sortfield == "") $sortfield = "t.numero_compte"; -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -$filter = array (); -if (! empty($search_date_start)) { +$filter = array(); +if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); } -if (! empty($search_date_end)) { +if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); } -if (! empty($search_accountancy_code_start)) { +if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.$search_accountancy_code_start; } -if (! empty($search_accountancy_code_end)) { +if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; } /* @@ -151,7 +151,7 @@ if ($action == 'export_csv') $filename = 'balance'; $type_export = 'balance'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); if ($result < 0) { @@ -160,11 +160,11 @@ if ($action == 'export_csv') foreach ($object->lines as $line) { - print length_accountg($line->numero_compte) . $sep; - print $object->get_compte_desc($line->numero_compte) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print price($line->debit - $line->credit) . $sep; + print length_accountg($line->numero_compte).$sep; + print $object->get_compte_desc($line->numero_compte).$sep; + print price($line->debit).$sep; + print price($line->credit).$sep; + print price($line->debit - $line->credit).$sep; print "\n"; } @@ -203,20 +203,20 @@ if ($action != 'export_csv') print ''; print ''; - $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); $moreforfilter = ''; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('DateStart') . ': '; - $moreforfilter .= $form->selectDate($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0); - $moreforfilter .= $langs->trans('DateEnd') . ': '; - $moreforfilter .= $form->selectDate($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0); + $moreforfilter .= $langs->trans('DateStart').': '; + $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); + $moreforfilter .= $langs->trans('DateEnd').': '; + $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); $moreforfilter .= '
'; - if (! empty($moreforfilter)) { + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; $parameters = array(); @@ -225,7 +225,7 @@ if ($action != 'export_csv') print '
'; } - print ''; + print '
'; print ''; print ''; print ''; @@ -265,7 +265,7 @@ if ($action != 'export_csv') $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); if (empty($description)) { - $link = '' . img_edit_add() . ''; + $link = ''.img_edit_add().''; } print ''; @@ -291,12 +291,12 @@ if ($action != 'export_csv') // $object->get_compte_racine($line->numero_compte); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; @@ -305,11 +305,11 @@ if ($action != 'export_csv') $sous_total_credit += $line->credit; } - print ''; + print ''; print "\n"; print ''; - print ''; + print ''; print "\n"; print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7a8a6612d4b..c1513a93a23 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -26,23 +26,23 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action', 'aZ09'); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); // id of record -$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' -$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) +$id = GETPOST('id', 'int'); // id of record +$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' +$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) // Security check if ($user->socid > 0) { @@ -66,14 +66,14 @@ $subledger_account = GETPOST('subledger_account', 'alphanohtml'); if ($subledger_account == - 1) { $subledger_account = null; } -$label_operation= GETPOST('label_operation', 'alphanohtml'); +$label_operation = GETPOST('label_operation', 'alphanohtml'); $debit = price2num(GETPOST('debit', 'alpha')); $credit = price2num(GETPOST('credit', 'alpha')); $save = GETPOST('save', 'alpha'); -if (! empty($save)) $action = 'add'; +if (!empty($save)) $action = 'add'; $update = GETPOST('update', 'alpha'); -if (! empty($update)) $action = 'confirm_update'; +if (!empty($update)) $action = 'confirm_update'; $object = new BookKeeping($db); @@ -88,16 +88,16 @@ if ($action == "confirm_update") { if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action='update'; + $action = 'update'; } if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action='update'; + $action = 'update'; } - if (! $error) + if (!$error) { $object = new BookKeeping($db); @@ -109,7 +109,7 @@ if ($action == "confirm_update") { $object->numero_compte = $accountingaccount_number; $object->subledger_account = $subledger_account; $object->label_compte = $accountingaccount_label; - $object->label_operation= $label_operation; + $object->label_operation = $label_operation; $object->debit = $debit; $object->credit = $credit; @@ -147,22 +147,22 @@ elseif ($action == "add") { { $error++; setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action=''; + $action = ''; } if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action=''; + $action = ''; } - if (! $error) { + if (!$error) { $object = new BookKeeping($db); $object->numero_compte = $accountingaccount_number; $object->subledger_account = $subledger_account; $object->label_compte = $accountingaccount_label; - $object->label_operation= $label_operation; + $object->label_operation = $label_operation; $object->debit = $debit; $object->credit = $credit; $object->doc_date = GETPOST('doc_date', 'alpha'); @@ -223,18 +223,18 @@ elseif ($action == "confirm_create") { $object = new BookKeeping($db); - if (! $journal_code || $journal_code == '-1') { + if (!$journal_code || $journal_code == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('next_num_mvt', 'alpha')) + if (!GETPOST('next_num_mvt', 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $object->label_compte = ''; $object->debit = 0; @@ -258,7 +258,7 @@ elseif ($action == "confirm_create") { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = 'update'; - $id=$object->id; + $id = $object->id; $piece_num = $object->piece_num; } } @@ -329,7 +329,7 @@ llxHeader('', $langs->trans("CreateMvts")); // Confirmation to delete the command if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -345,12 +345,12 @@ if ($action == 'create') dol_print_error('', 'Failed to get next piece number'); } - print ''; + print ''; if ($optioncss != '') print ''; print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; dol_fiche_head(); @@ -362,19 +362,19 @@ if ($action == 'create') print '';*/ print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -390,9 +390,9 @@ if ($action == 'create') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -403,15 +403,15 @@ if ($action == 'create') setEventMessages($object->error, $object->errors, 'errors'); } - if (! empty($object->piece_num)) + if (!empty($object->piece_num)) { - $backlink = '' . $langs->trans('BackToList') . ''; + $backlink = ''.$langs->trans('BackToList').''; print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); - $head=array(); - $h=0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:''); + $head = array(); + $h = 0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); $head[$h][1] = $langs->trans("Transaction"); $head[$h][2] = 'transaction'; $h++; @@ -428,8 +428,8 @@ if ($action == 'create') // Account movement print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Date @@ -438,17 +438,17 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print ''; + print ''; print '
'; @@ -236,7 +236,7 @@ if ($action != 'export_csv') print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->debit - $line->credit) . '' . $link; + print ''.length_accountg($line->numero_compte).''.$description.''.price($line->debit).''.price($line->credit).''.price($line->debit - $line->credit).''.$link; print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price(price2num($sous_total_debit - $sous_total_credit)) . '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).' 
' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price(price2num($total_debit - $total_credit)) . '
'.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).' 
' . $langs->trans("Docdate") . ''.$langs->trans("Docdate").''; print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); print '
' . $langs->trans("Codejournal") . '' . $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . ''.$langs->trans("Codejournal").''.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'
' . $langs->trans("Piece") . ''.$langs->trans("Piece").'
' . $langs->trans("NumMvts") . '' . $object->piece_num . ''.$langs->trans("NumMvts").''.$object->piece_num.'
piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
'; print ''; if ($action == 'editdate') { - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; + print ''; print '
'; } else { print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; @@ -462,20 +462,20 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editjournal') { - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; + print ''; print '
'; } else { - print $object->code_journal ; + print $object->code_journal; } print ''; print ''; @@ -486,20 +486,20 @@ if ($action == 'create') print $langs->trans('Piece'); print ''; if ($action != 'editdocref') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editdocref') { - print '
'; + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print '
'; } else { - print $object->doc_ref ; + print $object->doc_ref; } print ''; print ''; @@ -514,17 +514,17 @@ if ($action == 'create') print ''; // Doc type - if(! empty($object->doc_type)) + if (!empty($object->doc_type)) { print ''; - print ''; - print ''; + print ''; + print ''; print ''; } // Date document creation print ''; - print ''; + print ''; print ''; @@ -586,16 +586,16 @@ if ($action == 'create') } else { print load_fiche_titre($langs->trans("ListeMvts"), '', ''); - print ''; + print ''; if ($optioncss != '') print ''; print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print "
' . $langs->trans("Doctype") . '' . $object->doc_type . ''.$langs->trans("Doctype").''.$object->doc_type.'
' . $langs->trans("DateCreation") . ''.$langs->trans("DateCreation").''; print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; print '
"; if (count($object->linesmvt) > 0) { @@ -620,12 +620,12 @@ if ($action == 'create') if ($action == 'update' && $line->id == $id) { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; } else { $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; } print '
'; - print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array (), 1, 1, ''); + print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); } @@ -634,30 +634,30 @@ if ($action == 'create') print 'subledger_account).'">'; } print 'label_operation). '">debit)) . '">credit)) . '">label_operation).'">debit)).'">credit)).'">'; - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print '' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '' . length_accounta($line->subledger_account) . '' . $line->label_operation. '' . price($line->debit) . '' . price($line->credit) . ''.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''.length_accounta($line->subledger_account).''.$line->label_operation.''.price($line->debit).''.price($line->credit).''; - print 'id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">'; + print 'id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">'; print img_edit(); print '  '; - $actiontodelete='delete'; - if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete='confirm_delete'; + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete'; - print ''; + print ''; print img_delete(); print ''; @@ -677,12 +677,12 @@ if ($action == 'create') if ($action == "" || $action == 'add') { print '
'; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, ''); + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } @@ -694,19 +694,19 @@ if ($action == 'create') print '
'; - if ($mode=='_tmp' && $action=='') + if ($mode == '_tmp' && $action == '') { print '
'; print '
'; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { @@ -714,7 +714,7 @@ if ($action == 'create') } print '   '; - print ''.$langs->trans("Cancel").''; + print ''.$langs->trans("Cancel").''; print "
"; } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index f922ac06655..886b2ade2d4 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -29,12 +29,12 @@ class AccountingJournal extends CommonObject /** * @var string ID to identify managed object */ - public $element='accounting_journal'; + public $element = 'accounting_journal'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='accounting_journal'; + public $table_element = 'accounting_journal'; /** * @var int Field with ID of parent key if this field has a parent @@ -64,7 +64,7 @@ class AccountingJournal extends CommonObject */ public $label; - public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new public $active; public $lines; @@ -93,29 +93,29 @@ class AccountingJournal extends CommonObject if ($rowid || $journal_code) { $sql = "SELECT rowid, code, label, nature, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE"; if ($rowid) { - $sql .= " rowid = " . (int) $rowid; + $sql .= " rowid = ".(int) $rowid; } elseif ($journal_code) { - $sql .= " code = '" . $this->db->escape($journal_code) . "'"; - $sql .= " AND entity = " . $conf->entity; + $sql .= " code = '".$this->db->escape($journal_code)."'"; + $sql .= " AND entity = ".$conf->entity; } - 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); if ($obj) { - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->code = $obj->code; - $this->ref = $obj->code; + $this->ref = $obj->code; $this->label = $obj->label; $this->nature = $obj->nature; $this->active = $obj->active; @@ -127,8 +127,8 @@ class AccountingJournal extends CommonObject } 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; @@ -149,38 +149,38 @@ class AccountingJournal extends CommonObject public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; - $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) { if ($key == 't.code' || $key == 't.label' || $key == 't.nature') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.rowid' || $key == 't.active') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } } } $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $this->lines = array(); - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new self($this->db); $line->id = $obj->rowid; @@ -196,10 +196,10 @@ class AccountingJournal extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -217,34 +217,34 @@ class AccountingJournal extends CommonObject { global $langs, $conf, $user; - 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/journals_list.php?id=35'; + $url = DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35'; - $label = '' . $langs->trans("ShowAccountingJournal") . ''; - if (! empty($this->code)) - $label .= '
'.$langs->trans('Code') . ': ' . $this->code; - if (! empty($this->label)) - $label .= '
'.$langs->trans('Label') . ': ' . $langs->transnoentities($this->label); - if ($moretitle) $label.=' - '.$moretitle; + $label = ''.$langs->trans("ShowAccountingJournal").''; + if (!empty($this->code)) + $label .= '
'.$langs->trans('Code').': '.$this->code; + if (!empty($this->label)) + $label .= '
'.$langs->trans('Label').': '.$langs->transnoentities($this->label); + if ($moretitle) $label .= ' - '.$moretitle; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAccountingJournal"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowAccountingJournal"); + $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) { @@ -254,11 +254,11 @@ class AccountingJournal extends CommonObject } $label_link = $this->code; - if ($withlabel) $label_link .= ' - ' . $langs->transnoentities($this->label); + if ($withlabel) $label_link .= ' - '.$langs->transnoentities($this->label); $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.= $label_link; + 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 .= $label_link; $result .= $linkend; return $result; @@ -292,7 +292,7 @@ class AccountingJournal extends CommonObject if ($mode == 0) { - $prefix=''; + $prefix = ''; if ($nature == 9) return $langs->trans('AccountingJournalType9'); elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 193ca34e2f3..69c17f3484e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -25,7 +25,7 @@ */ // Class -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage Ledger (General Ledger and Subledger) @@ -60,7 +60,7 @@ class BookKeeping extends CommonObject /** * @var BookKeepingLine[] Lines */ - public $lines = array (); + public $lines = array(); /** * @var int ID @@ -230,17 +230,17 @@ class BookKeeping extends CommonObject $langs->loadLangs(array("errors")); if (in_array($this->doc_type, array('bank', 'expense_report'))) { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); + $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); } else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); - $mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; + $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; if ($this->subledger_account && $this->subledger_account != $this->numero_compte) { - $mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; + $mesg .= ', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; } - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); + $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); } return -1; @@ -256,13 +256,13 @@ class BookKeeping extends CommonObject // WARNING: This is not reliable, label may have been modified. This is just a small protection. // The page to make journalization make the test on couple doc_type - fk_doc only. $sql = "SELECT count(*) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; - $sql .= " AND fk_doc = " . $this->fk_doc; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; + $sql .= " AND fk_doc = ".$this->fk_doc; //$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines - $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; - $sql .= " AND label_operation = '" . $this->db->escape($this->label_operation) . "'"; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; + $sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); @@ -272,39 +272,39 @@ class BookKeeping extends CommonObject { // Determine piece_num $sqlnum = "SELECT piece_num"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' - $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... - $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object - $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sqlnum .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; // For example doc_type = 'bank' + $sqlnum .= " AND fk_docdet = ".$this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... + $sqlnum .= " AND doc_ref = '".$this->db->escape($this->doc_ref)."'"; // ref of source object + $sqlnum .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); + dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->piece_num; } - dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; - $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sqlnum .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); + dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->maxpiecenum; } } - dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); if (empty($this->piece_num)) { $this->piece_num = 1; } $now = dol_now(); - $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql .= "doc_date"; $sql .= ", date_lim_reglement"; $sql .= ", doc_type"; @@ -329,60 +329,60 @@ class BookKeeping extends CommonObject $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->doc_date)."'"; - $sql .= ", ".(! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); - $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; - $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; - $sql .= "," . $this->fk_doc; - $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; - $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; - $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; - $sql .= ",'" . $this->db->escape($this->label_operation) . "'"; - $sql .= "," . $this->debit; - $sql .= "," . $this->credit; - $sql .= "," . $this->montant; - $sql .= ",'" . $this->db->escape($this->sens) . "'"; - $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; + $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); + $sql .= ",'".$this->db->escape($this->doc_type)."'"; + $sql .= ",'".$this->db->escape($this->doc_ref)."'"; + $sql .= ",".$this->fk_doc; + $sql .= ",".$this->fk_docdet; + $sql .= ",'".$this->db->escape($this->thirdparty_code)."'"; + $sql .= ",'".$this->db->escape($this->subledger_account)."'"; + $sql .= ",'".$this->db->escape($this->subledger_label)."'"; + $sql .= ",'".$this->db->escape($this->numero_compte)."'"; + $sql .= ",'".$this->db->escape($this->label_compte)."'"; + $sql .= ",'".$this->db->escape($this->label_operation)."'"; + $sql .= ",".$this->debit; + $sql .= ",".$this->credit; + $sql .= ",".$this->montant; + $sql .= ",'".$this->db->escape($this->sens)."'"; + $sql .= ",'".$this->db->escape($this->fk_user_author)."'"; $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; - $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; - $sql .= "," . $this->db->escape($this->piece_num); - $sql .= ", " . (! isset($this->entity) ? $conf->entity : $this->entity); + $sql .= ",'".$this->db->escape($this->code_journal)."'"; + $sql .= ",'".$this->db->escape($this->journal_label)."'"; + $sql .= ",".$this->db->escape($this->piece_num); + $sql .= ", ".(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; - 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 . $this->table_element); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); if ($id > 0) { $this->id = $id; $result = 0; } else { $result = -2; - $error ++; - $this->errors[] = 'Error Create Error ' . $result . ' lecture ID'; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error Create Error '.$result.' lecture ID'; + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } else { $result = -1; - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } else { // Already exists $result = -3; $error++; - $this->error='BookkeepingRecordAlreadyExists'; - dol_syslog(__METHOD__ . ' ' . $this->error, LOG_WARNING); + $this->error = 'BookkeepingRecordAlreadyExists'; + dol_syslog(__METHOD__.' '.$this->error, LOG_WARNING); } } else { $result = -5; - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Uncomment this and change MYOBJECT to your own tag if you @@ -421,45 +421,45 @@ class BookKeeping 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("Transaction") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->piece_num; + $label = ''.$langs->trans("Transaction").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->piece_num; $url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num; 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("ShowTransaction"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowTransaction"); + $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 = ''; $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->piece_num; + 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->piece_num; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -551,7 +551,7 @@ class BookKeeping extends CommonObject $this->journal_label = $langs->trans($this->journal_label); // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.' ('; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' ('; $sql .= 'doc_date,'; $sql .= 'date_lim_reglement,'; $sql .= 'doc_type,'; @@ -575,41 +575,41 @@ class BookKeeping extends CommonObject $sql .= 'piece_num,'; $sql .= 'entity'; $sql .= ') VALUES ('; - $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'".$this->db->idate($this->doc_date)."'") . ','; - $sql .= ' ' . (! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'" . $this->db->idate($this->date_lim_reglement) . "'") . ','; - $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; - $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; - $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; - $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; - $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; - $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; - $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; - $sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ','; - $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; - $sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ','; - $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; - $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; - $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; - $sql .= ' ' . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ','; - $sql .= ' ' . $user->id . ','; - $sql .= ' ' . "'".$this->db->idate($now)."',"; - $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; - $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; - $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; - $sql .= ' ' . (! isset($this->entity) ? $conf->entity : $this->entity); + $sql .= ' '.(!isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'".$this->db->idate($this->doc_date)."'").','; + $sql .= ' '.(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'").','; + $sql .= ' '.(!isset($this->doc_type) ? 'NULL' : "'".$this->db->escape($this->doc_type)."'").','; + $sql .= ' '.(!isset($this->doc_ref) ? 'NULL' : "'".$this->db->escape($this->doc_ref)."'").','; + $sql .= ' '.(empty($this->fk_doc) ? '0' : $this->fk_doc).','; + $sql .= ' '.(empty($this->fk_docdet) ? '0' : $this->fk_docdet).','; + $sql .= ' '.(!isset($this->thirdparty_code) ? 'NULL' : "'".$this->db->escape($this->thirdparty_code)."'").','; + $sql .= ' '.(!isset($this->subledger_account) ? 'NULL' : "'".$this->db->escape($this->subledger_account)."'").','; + $sql .= ' '.(!isset($this->subledger_label) ? 'NULL' : "'".$this->db->escape($this->subledger_label)."'").','; + $sql .= ' '.(!isset($this->numero_compte) ? 'NULL' : "'".$this->db->escape($this->numero_compte)."'").','; + $sql .= ' '.(!isset($this->label_compte) ? 'NULL' : "'".$this->db->escape($this->label_compte)."'").','; + $sql .= ' '.(!isset($this->label_operation) ? 'NULL' : "'".$this->db->escape($this->label_operation)."'").','; + $sql .= ' '.(!isset($this->debit) ? 'NULL' : $this->debit).','; + $sql .= ' '.(!isset($this->credit) ? 'NULL' : $this->credit).','; + $sql .= ' '.(!isset($this->montant) ? 'NULL' : $this->montant).','; + $sql .= ' '.(!isset($this->sens) ? 'NULL' : "'".$this->db->escape($this->sens)."'").','; + $sql .= ' '.$user->id.','; + $sql .= ' '."'".$this->db->idate($now)."',"; + $sql .= ' '.(empty($this->code_journal) ? 'NULL' : "'".$this->db->escape($this->code_journal)."'").','; + $sql .= ' '.(empty($this->journal_label) ? 'NULL' : "'".$this->db->escape($this->journal_label)."'").','; + $sql .= ' '.(empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; + $sql .= ' '.(!isset($this->entity) ? $conf->entity : $this->entity); $sql .= ')'; $this->db->begin(); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element.$mode); // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -626,7 +626,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -673,13 +673,13 @@ class BookKeeping extends CommonObject $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; $sql .= " t.date_creation"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (null !== $ref) { - $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; + $sql .= ' AND t.ref = '.'\''.$ref.'\''; } else { - $sql .= ' AND t.rowid = ' . $id; + $sql .= ' AND t.rowid = '.$id; } $resql = $this->db->query($sql); @@ -721,10 +721,10 @@ class BookKeeping extends CommonObject return 0; } } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -777,21 +777,21 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num,"; $sql .= " t.date_creation"; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -799,19 +799,19 @@ class BookKeeping extends CommonObject } } } - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } // Affichage par compte comptable $sql .= ' ORDER BY t.numero_compte ASC'; - if (! empty($sortfield)) { - $sql .= ', ' . $sortfield . ' ' .$sortorder; + if (!empty($sortfield)) { + $sql .= ', '.$sortfield.' '.$sortorder; } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -858,8 +858,8 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -909,27 +909,27 @@ class BookKeeping extends CommonObject $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -937,18 +937,18 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; + $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; if ($showAlreadyExportMovements == 0) { $sql .= " AND t.date_export IS NULL"; } if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $this->lines = array(); @@ -996,8 +996,8 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } } @@ -1026,40 +1026,40 @@ class BookKeeping extends CommonObject $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter - $sqlwhere = array (); + $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$this->db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$this->db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.subledger_label') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } - $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')'; + $sql .= ' WHERE entity IN ('.getEntity('accountancy').')'; if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } $sql .= ' GROUP BY t.numero_compte'; - if (! empty($sortfield)) { + if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } - if (! empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit + 1, $offset); } $resql = $this->db->query($sql); @@ -1084,10 +1084,10 @@ class BookKeeping extends CommonObject return $num; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -1168,36 +1168,36 @@ class BookKeeping extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . $mode.' SET'; - $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'".$this->db->idate($this->doc_date)."'" : 'null') . ','; - $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; - $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; - $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; - $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; - $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ','; - $sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ','; - $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; - $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; - $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; - $sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ','; - $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; - $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; - $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; - $sql .= ' sens = ' . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ','; - $sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ','; - $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; - $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; - $sql .= ' journal_label = ' . (isset($this->journal_label) ? "'" . $this->db->escape($this->journal_label) . "'" : "null") . ','; - $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); - $sql .= ' WHERE rowid=' . $this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.$mode.' SET'; + $sql .= ' doc_date = '.(!isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'".$this->db->idate($this->doc_date)."'" : 'null').','; + $sql .= ' doc_type = '.(isset($this->doc_type) ? "'".$this->db->escape($this->doc_type)."'" : "null").','; + $sql .= ' doc_ref = '.(isset($this->doc_ref) ? "'".$this->db->escape($this->doc_ref)."'" : "null").','; + $sql .= ' fk_doc = '.(isset($this->fk_doc) ? $this->fk_doc : "null").','; + $sql .= ' fk_docdet = '.(isset($this->fk_docdet) ? $this->fk_docdet : "null").','; + $sql .= ' thirdparty_code = '.(isset($this->thirdparty_code) ? "'".$this->db->escape($this->thirdparty_code)."'" : "null").','; + $sql .= ' subledger_account = '.(isset($this->subledger_account) ? "'".$this->db->escape($this->subledger_account)."'" : "null").','; + $sql .= ' subledger_label = '.(isset($this->subledger_label) ? "'".$this->db->escape($this->subledger_label)."'" : "null").','; + $sql .= ' numero_compte = '.(isset($this->numero_compte) ? "'".$this->db->escape($this->numero_compte)."'" : "null").','; + $sql .= ' label_compte = '.(isset($this->label_compte) ? "'".$this->db->escape($this->label_compte)."'" : "null").','; + $sql .= ' label_operation = '.(isset($this->label_operation) ? "'".$this->db->escape($this->label_operation)."'" : "null").','; + $sql .= ' debit = '.(isset($this->debit) ? $this->debit : "null").','; + $sql .= ' credit = '.(isset($this->credit) ? $this->credit : "null").','; + $sql .= ' montant = '.(isset($this->montant) ? $this->montant : "null").','; + $sql .= ' sens = '.(isset($this->sens) ? "'".$this->db->escape($this->sens)."'" : "null").','; + $sql .= ' fk_user_author = '.(isset($this->fk_user_author) ? $this->fk_user_author : "null").','; + $sql .= ' import_key = '.(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").','; + $sql .= ' code_journal = '.(isset($this->code_journal) ? "'".$this->db->escape($this->code_journal)."'" : "null").','; + $sql .= ' journal_label = '.(isset($this->journal_label) ? "'".$this->db->escape($this->journal_label)."'" : "null").','; + $sql .= ' piece_num = '.(isset($this->piece_num) ? $this->piece_num : "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__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } // Uncomment this and change MYOBJECT to your own tag if you @@ -1214,7 +1214,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1233,19 +1233,19 @@ class BookKeeping extends CommonObject */ public function updateByMvt($piece_num = '', $field = '', $value = '', $mode = '') { - $error=0; + $error = 0; $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; - $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$this->db->escape($value)."'"); - $sql .= ' WHERE ab.piece_num=' . $piece_num ; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.$mode." as ab"; + $sql .= ' SET ab.'.$field.'='.(is_numeric($value) ? $value : "'".$this->db->escape($value)."'"); + $sql .= ' WHERE ab.piece_num='.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } if ($error) { $this->db->rollback(); @@ -1284,15 +1284,15 @@ class BookKeeping extends CommonObject // // End call triggers //} - if (! $error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= ' WHERE rowid=' . $this->id; + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= ' WHERE rowid='.$this->id; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } @@ -1300,7 +1300,7 @@ class BookKeeping extends CommonObject if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1320,16 +1320,16 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE import_key = '" . $this->db->escape($importkey) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE import_key = '".$this->db->escape($importkey)."'"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); $this->db->rollback(); - return - 1; + return -1; } $this->db->commit(); @@ -1357,18 +1357,18 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql.= " WHERE 1 = 1"; - if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between - if (! empty($journal)) $sql.= " AND code_journal = '".$this->db->escape($journal)."'"; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE 1 = 1"; + if (!empty($delyear)) $sql .= " AND YEAR(doc_date) = ".$delyear; // FIXME Must use between + if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); 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; @@ -1392,20 +1392,20 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE piece_num = " . (int) $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE piece_num = ".(int) $piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); - if (! $resql) { - $this->errors[] = "Error " . $this->db->lasterror(); + if (!$resql) { + $this->errors[] = "Error ".$this->db->lasterror(); 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; + return -1; } $this->db->commit(); @@ -1442,15 +1442,15 @@ class BookKeeping extends CommonObject // Other options if ($result < 0) { - $error ++; + $error++; $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } unset($object->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $object->id; @@ -1471,7 +1471,7 @@ class BookKeeping extends CommonObject { global $user; - $now=dol_now(); + $now = dol_now(); $this->id = 0; $this->doc_date = $now; @@ -1509,11 +1509,11 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -1526,9 +1526,9 @@ class BookKeeping extends CommonObject $this->doc_type = $obj->doc_type; $this->date_creation = $obj->date_creation; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR); + return -1; } return 1; @@ -1544,10 +1544,10 @@ class BookKeeping extends CommonObject { global $conf; - $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sql = "SELECT MAX(piece_num)+1 as max FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."getNextNumMvt sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1556,9 +1556,9 @@ class BookKeeping extends CommonObject if (empty($result)) $result = 1; return $result; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::getNextNumMvt ".$this->error, LOG_ERR); + return -1; } } @@ -1577,11 +1577,11 @@ class BookKeeping extends CommonObject $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; - $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; + $sql .= " WHERE piece_num = ".$piecenum; + $sql .= " AND entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { @@ -1612,9 +1612,9 @@ class BookKeeping extends CommonObject $this->linesmvt[] = $line; } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR); + return -1; } return 1; @@ -1636,15 +1636,15 @@ class BookKeeping extends CommonObject $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::export_bookkeeping", LOG_DEBUG); + dol_syslog(get_class($this)."::export_bookkeeping", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->linesexport = array (); + $this->linesexport = array(); $num = $this->db->num_rows($resql); while ($obj = $this->db->fetch_object($resql)) { @@ -1676,9 +1676,9 @@ class BookKeeping extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::export_bookkeeping " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::export_bookkeeping ".$this->error, LOG_ERR); + return -1; } } @@ -1695,45 +1695,45 @@ class BookKeeping extends CommonObject $this->db->begin(); - if ($direction==0) + if ($direction == 0) { - $next_piecenum=$this->getNextNumMvt(); + $next_piecenum = $this->getNextNumMvt(); $now = dol_now(); if ($next_piecenum < 0) { $error++; } - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . ' (doc_date, doc_type,'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)'; $sql .= ' SELECT doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, ' . $next_piecenum . ", '".$this->db->idate($now)."'"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $this->db->escape($piece_num); + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $this->db->escape($piece_num); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$this->db->escape($piece_num); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - } elseif ($direction==1) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $piece_num; + } elseif ($direction == 1) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '_tmp (doc_date, doc_type,'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)'; @@ -1741,27 +1741,27 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.' WHERE piece_num = ' . $piece_num; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element . '_tmp WHERE piece_num = ' . $piece_num; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.$piece_num; $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; } else { $this->db->rollback(); - return - 1; + return -1; } /* $sql = "DELETE FROM "; @@ -1793,26 +1793,26 @@ class BookKeeping extends CommonObject // phpcs:enable global $conf; - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.account_number = ab.numero_compte"; $sql .= " AND aa.active = 1"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $pcgver; - $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = ".$pcgver; + $sql .= " AND ab.entity IN (".getEntity('accountancy').")"; $sql .= " ORDER BY account_number ASC"; - dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); + dol_syslog(get_class($this)."::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return - 1; + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR); + return -1; } $out = ajax_combobox($htmlname, $event); @@ -1821,7 +1821,7 @@ class BookKeeping extends CommonObject $selected = null; while ($obj = $this->db->fetch_object($resql)) { - $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + $label = length_accountg($obj->account_number).' - '.$obj->label; $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; @@ -1861,17 +1861,17 @@ class BookKeeping extends CommonObject $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT root.account_number, root.label as label"; - $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 = " . $pcgver; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $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 = ".$pcgver; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid"; + $sql .= " WHERE aa.account_number = '".$account."'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; - $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " AND aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; @@ -1881,8 +1881,8 @@ class BookKeeping extends CommonObject return $obj->label; } 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; } @@ -1902,29 +1902,29 @@ class BookKeeping extends CommonObject $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; - $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 aa.account_number = '" . $account . "'"; - $sql .= " AND asy.rowid = " . $pcgver; + $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 aa.account_number = '".$account."'"; + $sql .= " AND asy.rowid = ".$pcgver; $sql .= " AND aa.active = 1"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; - $sql .= " WHERE aa.entity IN (" . getEntity('accountancy') . ")"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; + $sql .= " WHERE aa.entity IN (".getEntity('accountancy').")"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); } - if(empty($obj->category)){ + if (empty($obj->category)) { return $obj->label; - }else{ + } else { return $obj->label.' ('.$obj->category.')'; } } 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/index.php b/htdocs/accountancy/index.php index 8dde1d0df22..71fce0be43a 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -24,12 +24,12 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict")); +$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict")); // Security check if ($user->socid > 0) @@ -45,12 +45,12 @@ $hookmanager->initHooks(array('accountancyindex')); if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone=GETPOST('areacode', 'aZ09'); - $userid=GETPOST('userid', 'int'); - $boxorder=GETPOST('boxorder', 'aZ09'); - $boxorder.=GETPOST('boxcombo', 'aZ09'); + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } @@ -64,16 +64,16 @@ if ($conf->accounting->enabled) { $step = 0; - $resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. + $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; - if (! $helpisexpanded) + if (!$helpisexpanded) { $showtutorial = '
'; $showtutorial .= img_picto('', 'chevron-down'); - $showtutorial .= ' ' . $langs->trans("ShowTutorial"); + $showtutorial .= ' '.$langs->trans("ShowTutorial"); $showtutorial .= '
'; $showtutorial .= ''."\n"; - $formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); print ''; print ''; @@ -1509,13 +1509,13 @@ if ($id > 0) print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', $object->note, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('note', $object->note, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1622,7 +1622,7 @@ if ($id > 0) print ''; // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } @@ -1630,12 +1630,12 @@ if ($id > 0) // Full day event print ''; - $rowspan=4; + $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; // Date start print ''; @@ -1643,9 +1643,9 @@ if ($id > 0) // Date end print ''; // Location @@ -1656,41 +1656,41 @@ if ($id > 0) // Assigned to print ''; // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm. - if (! empty($object->fk_element) && ! empty($object->elementtype) && ! in_array($object->elementtype, array('societe','contact','project'))) + if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe', 'contact', 'project'))) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; - $link=dolGetElementUrl($object->fk_element, $object->elementtype, 1); + $link = dolGetElementUrl($object->fk_element, $object->elementtype, 1); print ''; // Other attributes - $cols=3; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $cols = 3; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("Type").''.$langs->trans($object->type).'
'.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).'
'.$langs->trans("DateActionStart").''; - if (! $object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); else print dol_print_date($object->datep, 'day'); if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
'.$langs->trans("DateActionEnd").''; - if (! $object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); else print dol_print_date($object->datef, 'day'); - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
'.$langs->trans("ActionAssignedTo").''; - $listofuserid=array(); + $listofuserid = array(); if (empty($donotclearsession)) { if ($object->userownerid > 0) { - $listofuserid[$object->userownerid]=array( + $listofuserid[$object->userownerid] = array( 'id'=>$object->userownerid, - 'transparency'=>$object->transparency, // Force transparency on onwer from preoperty of event + 'transparency'=>$object->transparency, // Force transparency on onwer from preoperty of event 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] ); } - if (! empty($object->userassigned)) // Now concat assigned users + if (!empty($object->userassigned)) // Now concat assigned users { // Restore array with key with same value than param 'id' - $tmplist1=$object->userassigned; - foreach($tmplist1 as $key => $val) + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; } } - $_SESSION['assignedtouser']=json_encode($listofuserid); + $_SESSION['assignedtouser'] = json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { - $listofuserid=json_decode($_SESSION['assignedtouser'], true); + $listofuserid = json_decode($_SESSION['assignedtouser'], true); } } - $listofcontactid=array(); // not used yet - $listofotherid=array(); // not used yet + $listofcontactid = array(); // not used yet + $listofotherid = array(); // not used yet print '
'; - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); print '
'; /* if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) @@ -1710,7 +1710,7 @@ if ($id > 0) print '
'.$langs->trans("ActionDoneBy").''; if ($object->userdoneid > 0) { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($object->userdoneid); print $tmpuser->getNomUrl(1); } @@ -1727,7 +1727,7 @@ if ($id > 0) if ($conf->societe->enabled) { // Related company - print '
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):(''.$langs->trans("None").'')); + print '
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) @@ -1770,16 +1770,16 @@ if ($id > 0) // Priority print '
'.$langs->trans("Priority").''; - print ($object->priority?$object->priority:''); + print ($object->priority ? $object->priority : ''); print '
'.$langs->trans("LinkedObject").''; if (empty($link)) print ''.$langs->trans("ObjectDeleted").''; else print $link; @@ -1792,8 +1792,8 @@ if ($id > 0) print '
'; @@ -1809,8 +1809,8 @@ if ($id > 0) print '
'; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($action != 'edit') @@ -1860,11 +1860,11 @@ if ($id > 0) * Documents generes */ - $filedir=$conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->agenda->myactions->read; - $delallowed=$user->rights->agenda->myactions->create; + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a0263065dee..00ad6c9aa00 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -72,8 +72,8 @@ 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="nom"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "nom"; $cancelbutton = GETPOST('cancel', 'alpha'); $object = new Client($db); @@ -83,7 +83,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartycomm','globalcard')); +$hookmanager->initHooks(array('thirdpartycomm', 'globalcard')); @@ -99,15 +99,15 @@ if (empty($reshook)) { if ($cancelbutton) { - $action=""; + $action = ""; } // set accountancy code if ($action == 'setcustomeraccountancycode') { - $result=$object->fetch($id); - $object->code_compta=$_POST["customeraccountancycode"]; - $result=$object->update($object->id, $user, 1, 1, 0); + $result = $object->fetch($id); + $object->code_compta = $_POST["customeraccountancycode"]; + $result = $object->update($object->id, $user, 1, 1, 0); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -115,7 +115,7 @@ if (empty($reshook)) if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -123,7 +123,7 @@ if (empty($reshook)) if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -131,7 +131,7 @@ if (empty($reshook)) if ($action == 'setbankaccount' && $user->rights->societe->creer) { $object->fetch($id); - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -147,8 +147,8 @@ if (empty($reshook)) if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); - $object->tva_assuj=$_POST['assujtva_value']; - $result=$object->update($object->id); + $object->tva_assuj = $_POST['assujtva_value']; + $result = $object->update($object->id); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -156,8 +156,8 @@ if (empty($reshook)) if ($action == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($id); - $object->fk_prospectlevel=GETPOST('prospect_level_id', 'alpha'); - $result=$object->update($object->id, $user); + $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -165,8 +165,8 @@ if (empty($reshook)) if ($action == 'setstcomm') { $object->fetch($id); - $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); - $result=$object->update($object->id, $user); + $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -174,8 +174,8 @@ if (empty($reshook)) if ($action == 'setoutstanding_limit') { $object->fetch($id); - $object->outstanding_limit=GETPOST('outstanding_limit'); - $result=$object->update($object->id, $user); + $object->outstanding_limit = GETPOST('outstanding_limit'); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,8 +183,8 @@ if (empty($reshook)) if ($action == 'setorder_min_amount') { $object->fetch($id); - $object->order_min_amount=price2num(GETPOST('order_min_amount', 'alpha')); - $result=$object->update($object->id, $user); + $object->order_min_amount = price2num(GETPOST('order_min_amount', 'alpha')); + $result = $object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -196,7 +196,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) @@ -215,20 +215,20 @@ if (empty($reshook)) */ $contactstatic = new Contact($db); -$userstatic=new User($db); +$userstatic = new User($db); $form = new Form($db); -$formcompany=new FormCompany($db); +$formcompany = new FormCompany($db); if ($id > 0 && empty($object->id)) { // Load data of third party - $res=$object->fetch($id); + $res = $object->fetch($id); if ($object->id < 0) dol_print_error($db, $object->error, $object->errors); } -$title=$langs->trans("CustomerCard"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("CustomerCard"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -253,10 +253,10 @@ if ($object->id > 0) print ''; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans("Prefix").''; - print ($object->prefix_comm?$object->prefix_comm:' '); + print ($object->prefix_comm ? $object->prefix_comm : ' '); print ''; } @@ -298,13 +298,13 @@ if ($object->id > 0) if ($mysoc->country_code == 'ES') { // Local Taxes - if ($mysoc->localtax1_assuj=="1") + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print ''; } - if ($mysoc->localtax1_assuj=="1") + if ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); @@ -356,7 +356,7 @@ if ($object->id > 0) print ""; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Compte bancaire par défaut print ''; @@ -392,7 +392,7 @@ if ($object->id > 0) print ''.img_edit($langs->trans("Modify")).''; } print ''; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; + print ''.($object->remise_percent ? ''.$object->remise_percent.'%' : '').''; print ''; // Absolute discounts (Discounts-Drawbacks-Rebates) @@ -408,7 +408,7 @@ if ($object->id > 0) print ''; print ''; print ''; - $amount_discount=$object->getAvailableDiscounts(); + $amount_discount = $object->getAvailableDiscounts(); if ($amount_discount < 0) dol_print_error($db, $object->error); if ($amount_discount > 0) print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; //else print $langs->trans("DiscountNone"); @@ -423,7 +423,7 @@ if ($object->id > 0) print ''; print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); print ''; - $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; + $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); print ''; print ''; @@ -431,7 +431,7 @@ if ($object->id > 0) if ($object->client) { - if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) + if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) { print ''."\n"; print ''; @@ -446,7 +446,7 @@ if ($object->id > 0) // Multiprice level - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { print ''; print '
'; @@ -459,14 +459,14 @@ if ($object->id > 0) print '
'; print ''; print $object->price_level; - $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$object->price_level; - if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$object->price_level; + if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print ""; print ''; } // Preferred shipping Method - if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { print ''; print ''; + print ''; print '"; } // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("users"); print ''; print ''; @@ -574,65 +574,65 @@ if ($object->id > 0) $boxstat = ''; // Nbre max d'elements des petites listes - $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Lien recap - $boxstat.='
'; - $boxstat.='
'; print $langs->trans('SendingMethod'); @@ -489,32 +489,32 @@ if ($object->id > 0) // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load("categories"); - print '
' . $langs->trans("CustomersCategoriesShort") . '
'.$langs->trans("CustomersCategoriesShort").''; print $form->showCategories($object->id, 'customer', 1); print "
'.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $object->id); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $object->id); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); } else @@ -558,10 +558,10 @@ if ($object->id > 0) print '
'.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '     '; print '
'; - foreach($object->cacheprospectstatus as $key => $val) + foreach ($object->cacheprospectstatus as $key => $val) { - $titlealt='default'; - if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; } print '
'; - $boxstat.=''; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= ''; + $boxstat .= ''; - $boxstat.='
'; - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { // Box proposals $tmp = $object->getOutstandingProposals(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllProposals"); - $link=DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("", $icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllProposals"); + $link = DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; } - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { // Box commandes $tmp = $object->getOutstandingOrders(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllOrders"); - $link=DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("", $icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllOrders"); + $link = DOL_URL_ROOT.'/commande/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { // Box factures $tmp = $object->getOutstandingBills(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllInvoices"); - $link=DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("", $icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + $outstandingOpened = $tmp['opened']; + $outstandingTotal = $tmp['total_ht']; + $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllInvoices"); + $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; // Box outstanding bill $warn = ''; @@ -640,50 +640,50 @@ if ($object->id > 0) { $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } - $text=$langs->trans("CurrentOutstandingBill"); - $link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("", $icon).' '.$text.'
'; - $boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + $text = $langs->trans("CurrentOutstandingBill"); + $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; + $boxstat .= '
'; + if ($link) $boxstat .= '
'; } $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action); - if(empty($reshook)){ - $boxstat.= $hookmanager->resPrint; + if (empty($reshook)) { + $boxstat .= $hookmanager->resPrint; } - $boxstat.='
'; - $boxstat.='
'; + $boxstat .= '
'; + $boxstat .= '
'; print $boxstat; - $now=dol_now(); + $now = dol_now(); /* * Last proposals */ - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; - $sql.= ", p.tva as total_tva"; - $sql.= ", p.total as total_ttc"; - $sql.= ", p.ref, p.ref_client, p.remise"; - $sql.= ", p.datep as dp, p.fin_validite as datelimite"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " ORDER BY p.datep DESC"; + $sql .= ", p.tva as total_tva"; + $sql .= ", p.total as total_ttc"; + $sql .= ", p.ref, p.ref_client, p.remise"; + $sql .= ", p.datep as dp, p.fin_validite as datelimite"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " ORDER BY p.datep DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $propal_static = new Propal($db); @@ -695,7 +695,7 @@ if ($object->id > 0) print ''; print ''; - print '
'; + print ''; print ''; @@ -715,7 +715,7 @@ if ($object->id > 0) $propal_static->total_tva = $objp->total_tva; $propal_static->total_ttc = $objp->total_ttc; print $propal_static->getNomUrl(1); - if ( ($db->jdate($objp->datelimite) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) { + if (($db->jdate($objp->datelimite) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1) { print " ".img_warning(); } print '\n"; @@ -740,39 +740,39 @@ if ($object->id > 0) /* * Last orders */ - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql = "SELECT s.nom, s.rowid"; - $sql.= ", c.rowid as cid, c.total_ht"; - $sql.= ", c.tva as total_tva"; - $sql.= ", c.total_ttc"; - $sql.= ", c.ref, c.ref_client, c.fk_statut, c.facture"; - $sql.= ", c.date_commande as dc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.fk_soc = s.rowid "; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.date_commande DESC"; + $sql .= ", c.rowid as cid, c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture"; + $sql .= ", c.date_commande as dc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.fk_soc = s.rowid "; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.date_commande DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $commande_static=new Commande($db); + $commande_static = new Commande($db); $num = $db->num_rows($resql); if ($num > 0) { // Check if there are orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; - $sql2.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; - $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; - $sql2.= ', '.MAIN_DB_PREFIX.'commande as c'; - $sql2.= ' WHERE c.fk_soc = s.rowid'; - $sql2.= ' AND s.rowid = '.$object->id; + $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; + $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql2 .= ', '.MAIN_DB_PREFIX.'commande as c'; + $sql2 .= ' WHERE c.fk_soc = s.rowid'; + $sql2 .= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; + $sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); $orders2invoice = $db->num_rows($resql2); $db->free($resql2); @@ -780,7 +780,7 @@ if ($object->id > 0) print '
'.$langs->trans("LastPropals", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''; print ''; print '
'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'.dol_print_date($db->jdate($objp->dp), 'day')."
'; print ''; - print ''; } else { - $out.=''; + $out .= ''; } // Status - $out.=''; + $out .= ''; // Actions - $out.=''; + $out .= ''; - $out.="\n"; + $out .= "\n"; $i++; } - $out.="
'; + print ''; + print ''; $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); @@ -545,10 +545,10 @@ if ($object->id > 0) $remaintopaylesspendingdebit = $resteapayer - $pending; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } @@ -596,14 +596,14 @@ if ($object->id > 0) print ''; $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; - $sql.= " , pfd.date_traite as date_traite, pfd.amount,"; - $sql.= " u.rowid as user_id, u.lastname, u.firstname, u.login"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql.= " WHERE fk_facture = ".$object->id; - $sql.= " AND pfd.traite = 0"; - $sql.= " ORDER BY pfd.date_demande DESC"; + $sql .= " , pfd.date_traite as date_traite, pfd.amount,"; + $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; + $sql .= " WHERE fk_facture = ".$object->id; + $sql .= " AND pfd.traite = 0"; + $sql .= " ORDER BY pfd.date_demande DESC"; $result_sql = $db->query($sql); @@ -646,14 +646,14 @@ if ($object->id > 0) // Past requests $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; - $sql.= " pb.ref,"; - $sql.= " u.rowid as user_id, u.lastname, u.firstname, u.login"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql.= " WHERE fk_facture = ".$object->id; - $sql.= " AND pfd.traite = 1"; - $sql.= " ORDER BY pfd.date_demande DESC"; + $sql .= " pb.ref,"; + $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; + $sql .= " WHERE fk_facture = ".$object->id; + $sql .= " AND pfd.traite = 1"; + $sql .= " ORDER BY pfd.date_demande DESC"; $result = $db->query($sql); if ($result) @@ -677,9 +677,9 @@ if ($object->id > 0) print '\n"; @@ -694,7 +694,7 @@ if ($object->id > 0) $i++; } - if (! $numopen && ! $numclosed) + if (!$numopen && !$numclosed) print ''; $db->free($result); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3f1e4aef717..609181dec96 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -42,21 +42,21 @@ $langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency')); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$facid = GETPOST('facid', 'int'); -$accountid = GETPOST('accountid', 'int'); +$facid = GETPOST('facid', 'int'); +$accountid = GETPOST('accountid', 'int'); $paymentnum = GETPOST('num_paiement', 'alpha'); $socid = GETPOST('socid', 'int'); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOST('page', 'int'); -$amounts=array(); -$amountsresttopay=array(); -$addwarning=0; +$amounts = array(); +$amountsresttopay = array(); +$addwarning = 0; -$multicurrency_amounts=array(); -$multicurrency_amountsresttopay=array(); +$multicurrency_amounts = array(); +$multicurrency_amountsresttopay = array(); // Security check if ($user->socid > 0) @@ -64,24 +64,24 @@ if ($user->socid > 0) $socid = $user->socid; } -$object=new Facture($db); +$object = new Facture($db); // Load object if ($facid > 0) { - $ret=$object->fetch($facid); + $ret = $object->fetch($facid); } // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard','globalcard')); +$hookmanager->initHooks(array('paiementcard', 'globalcard')); /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -97,7 +97,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice = new Facture($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') @@ -105,16 +105,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -126,23 +126,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -154,18 +154,18 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } // Check parameters - if (! GETPOST('paiementcode')) + if (!GETPOST('paiementcode')) { setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -212,7 +212,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); @@ -244,7 +244,7 @@ if (empty($reshook)) } } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement if (GETPOST('accountid', 'int') <= 0) @@ -257,17 +257,17 @@ if (empty($reshook)) // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_paiement = GETPOST('num_paiement', 'alpha'); $paiement->note = GETPOST('comment', 'alpha'); - if (! $error) + if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty); // This include closing invoices and regenerating documents + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -275,11 +275,11 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -287,19 +287,19 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; @@ -319,7 +319,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("Payment")); @@ -335,31 +335,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $facture->fetch_thirdparty(); - $title=''; - if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title.=$langs->trans("EnterPaymentDueToCustomer"); + $title = ''; + if ($facture->type != Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $title .= $langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) if ($action == 'add_paiement') { - $i=0; + $i = 0; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); } // Invoice with Paypal transaction // TODO add hook possibility (regis) - if (! empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && ! empty($facture->ref_int)) + if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_int)) { - if (! empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid=$conf->global->PAYPAL_BANK_ACCOUNT; - $paymentnum=$facture->ref_int; + if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; + $paymentnum = $facture->ref_int; } // Add realtime total information - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; + $this->stringtoshow .= 'plotWithOptions_'.$tag.'();'."\n"; + $this->stringtoshow .= '});'."\n"; + $this->stringtoshow .= ''."\n"; } @@ -1138,8 +1138,8 @@ class DolGraph if ($shownographyet) { - $s= '
'; - $s.='
'.$langs->trans("NotEnoughDataYet").'
'; + $s = '
'; + $s .= '
'.$langs->trans("NotEnoughDataYet").'
'; return $s; } @@ -1161,11 +1161,11 @@ class DolGraph if ($direction == 'width') { if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500'); - else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width']-40)); + else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40)); } if ($direction == 'height') { - return (empty($conf->dol_optimize_smallscreen)?($defaultsize?$defaultsize:'200'):'160'); + return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160'); } return 0; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8567ef595a0..81dffc51b67 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -140,7 +140,7 @@ class ExtraFields /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Array of Error code (or message) @@ -153,7 +153,7 @@ class ExtraFields public $errno; - public static $type2label=array( + public static $type2label = array( 'varchar'=>'String', 'text'=>'TextLong', 'html'=>'HtmlText', @@ -280,67 +280,67 @@ class ExtraFields */ private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') ||($type=='checkbox') ||($type=='chkbxlst')){ - $typedb='varchar'; - $lengthdb='255'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif ($type=='html') { - $typedb='text'; - $lengthdb=$length; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='128'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'html') { + $typedb = 'text'; + $lengthdb = $length; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '128'; } else { - $typedb=$type; - $lengthdb=$length; - if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255'; + $typedb = $type; + $lengthdb = $length; + if ($type == 'varchar' && empty($lengthdb)) $lengthdb = '255'; } $field_desc = array( 'type'=>$typedb, 'value'=>$lengthdb, - 'null'=>($required?'NOT NULL':'NULL'), + 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default' => $default_value ); - $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; - $resql=$this->db->query($sql, 1, 'dml'); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $resql = $this->db->query($sql, 1, 'dml'); } return 1; } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -378,19 +378,19 @@ class ExtraFields private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; // Clean parameters - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && ! is_numeric($attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) { if (is_array($param) && count($param) > 0) { @@ -460,8 +460,8 @@ class ExtraFields } else { - $this->error=$this->db->lasterror(); - $this->errno=$this->db->lasterrno(); + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); return -1; } } @@ -476,30 +476,30 @@ class ExtraFields */ public function delete($attrname, $elementtype = 'member') { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; - $error=0; + $error = 0; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) + if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - $result=$this->delete_label($attrname, $elementtype); + $result = $this->delete_label($attrname, $elementtype); if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE elementtype = '".$elementtype."'"; - $sql.= " AND name = '".$attrname."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " WHERE elementtype = '".$elementtype."'"; + $sql .= " AND name = '".$attrname."'"; //$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table $resql = $this->db->query($sql); if ($resql) @@ -507,11 +507,11 @@ class ExtraFields $obj = $this->db->fetch_object($resql); if ($obj->nb <= 0) { - $result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key + $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key if ($result < 0) { - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } } @@ -539,18 +539,18 @@ class ExtraFields // phpcs:enable global $conf; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql.= " WHERE name = '".$attrname."'"; - $sql.= " AND entity IN (0,".$conf->entity.')'; - $sql.= " AND elementtype = '".$elementtype."'"; + $sql .= " WHERE name = '".$attrname."'"; + $sql .= " AND entity IN (0,".$conf->entity.')'; + $sql .= " AND elementtype = '".$elementtype."'"; dol_syslog(get_class($this)."::delete_label", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return 1; @@ -593,80 +593,80 @@ class ExtraFields */ public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0) { - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table=$elementtype.'_extrafields'; - if ($elementtype == 'categorie') $table='categories_extrafields'; + $table = $elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table = 'categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { - if ($type=='boolean') { - $typedb='int'; - $lengthdb='1'; - } elseif($type=='price') { - $typedb='double'; - $lengthdb='24,8'; - } elseif($type=='phone') { - $typedb='varchar'; - $lengthdb='20'; - } elseif($type=='mail') { - $typedb='varchar'; - $lengthdb='128'; - } elseif($type=='url') { - $typedb='varchar'; - $lengthdb='255'; - } elseif (($type=='select') || ($type=='sellist') || ($type=='radio') || ($type=='checkbox') || ($type=='chkbxlst')) { - $typedb='varchar'; - $lengthdb='255'; + if ($type == 'boolean') { + $typedb = 'int'; + $lengthdb = '1'; + } elseif ($type == 'price') { + $typedb = 'double'; + $lengthdb = '24,8'; + } elseif ($type == 'phone') { + $typedb = 'varchar'; + $lengthdb = '20'; + } elseif ($type == 'mail') { + $typedb = 'varchar'; + $lengthdb = '128'; + } elseif ($type == 'url') { + $typedb = 'varchar'; + $lengthdb = '255'; + } elseif (($type == 'select') || ($type == 'sellist') || ($type == 'radio') || ($type == 'checkbox') || ($type == 'chkbxlst')) { + $typedb = 'varchar'; + $lengthdb = '255'; } elseif ($type == 'html') { - $typedb='text'; - } elseif ($type=='link') { - $typedb='int'; - $lengthdb='11'; - } elseif($type=='password') { - $typedb='varchar'; - $lengthdb='50'; + $typedb = 'text'; + } elseif ($type == 'link') { + $typedb = 'int'; + $lengthdb = '11'; + } elseif ($type == 'password') { + $typedb = 'varchar'; + $lengthdb = '50'; } else { - $typedb=$type; - $lengthdb=$length; + $typedb = $type; + $lengthdb = $length; } - $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'), 'default'=>$default); + $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default'=>$default); if ($type != 'separate') // No table update when separate type { - $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + $result = $this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); } if ($result > 0 || $type == 'separate') { if ($label) { - $result=$this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); + $result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable); } if ($result > 0) { - $sql=''; + $sql = ''; if ($unique) { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")"; } else { - $sql="ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; + $sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table." DROP INDEX uk_".$table."_".$attrname; } dol_syslog(get_class($this).'::update', LOG_DEBUG); - $resql=$this->db->query($sql, 1, 'dml'); + $resql = $this->db->query($sql, 1, 'dml'); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -708,17 +708,17 @@ class ExtraFields dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable); // Clean parameters - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; - if (empty($pos)) $pos=0; - if (empty($list)) $list='0'; + if (empty($pos)) $pos = 0; + if (empty($list)) $list = '0'; if (empty($totalizable)) { $totalizable = 0; } - if (empty($required)) $required=0; - if (empty($unique)) $unique=0; - if (empty($alwayseditable)) $alwayseditable=0; + if (empty($required)) $required = 0; + if (empty($unique)) $unique = 0; + if (empty($alwayseditable)) $alwayseditable = 0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) { @@ -734,76 +734,76 @@ class ExtraFields } else { - $params=''; + $params = ''; } if ($entity === '' || $entity != '0') { // We dont want on all entities, we delete all and current $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity IN (0, ".($entity===''?$conf->entity:$entity).")"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity IN (0, ".($entity === '' ? $conf->entity : $entity).")"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } else { // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity) $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity = 0"; - $sql_del.= " AND elementtype = '".$elementtype."'"; + $sql_del .= " WHERE name = '".$attrname."'"; + $sql_del .= " AND entity = 0"; + $sql_del .= " AND elementtype = '".$elementtype."'"; } - $resql1=$this->db->query($sql_del); + $resql1 = $this->db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields("; - $sql.= " name,"; // This is code - $sql.= " entity,"; - $sql.= " label,"; - $sql.= " type,"; - $sql.= " size,"; - $sql.= " elementtype,"; - $sql.= " fieldunique,"; - $sql.= " fieldrequired,"; - $sql.= " perms,"; - $sql.= " langs,"; - $sql.= " pos,"; - $sql.= " alwayseditable,"; - $sql.= " param,"; - $sql.= " list,"; - $sql.= " totalizable,"; - $sql.= " fielddefault,"; - $sql.= " fieldcomputed,"; - $sql.= " fk_user_author,"; - $sql.= " fk_user_modif,"; - $sql.= " datec,"; - $sql.= " enabled,"; - $sql.= " help"; - $sql.= ") VALUES ("; - $sql.= "'".$attrname."',"; - $sql.= " ".($entity===''?$conf->entity:$entity).","; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$this->db->escape($type)."',"; - $sql.= " '".$this->db->escape($size)."',"; - $sql.= " '".$this->db->escape($elementtype)."',"; - $sql.= " ".$unique.","; - $sql.= " ".$required.","; - $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; - $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$pos.","; - $sql.= " '".$this->db->escape($alwayseditable)."',"; - $sql.= " '".$this->db->escape($params)."',"; - $sql.= " '".$this->db->escape($list)."', "; - $sql.= " ".$totalizable.","; - $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; - $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . $user->id . ","; - $sql .= " " . $user->id . ","; - $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql .= "'" . $this->db->escape($enabled). "',"; - $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); - $sql.= ")"; + $sql .= " name,"; // This is code + $sql .= " entity,"; + $sql .= " label,"; + $sql .= " type,"; + $sql .= " size,"; + $sql .= " elementtype,"; + $sql .= " fieldunique,"; + $sql .= " fieldrequired,"; + $sql .= " perms,"; + $sql .= " langs,"; + $sql .= " pos,"; + $sql .= " alwayseditable,"; + $sql .= " param,"; + $sql .= " list,"; + $sql .= " totalizable,"; + $sql .= " fielddefault,"; + $sql .= " fieldcomputed,"; + $sql .= " fk_user_author,"; + $sql .= " fk_user_modif,"; + $sql .= " datec,"; + $sql .= " enabled,"; + $sql .= " help"; + $sql .= ") VALUES ("; + $sql .= "'".$attrname."',"; + $sql .= " ".($entity === '' ? $conf->entity : $entity).","; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$this->db->escape($type)."',"; + $sql .= " '".$this->db->escape($size)."',"; + $sql .= " '".$this->db->escape($elementtype)."',"; + $sql .= " ".$unique.","; + $sql .= " ".$required.","; + $sql .= " ".($perms ? "'".$this->db->escape($perms)."'" : "null").","; + $sql .= " ".($langfile ? "'".$this->db->escape($langfile)."'" : "null").","; + $sql .= " ".$pos.","; + $sql .= " '".$this->db->escape($alwayseditable)."',"; + $sql .= " '".$this->db->escape($params)."',"; + $sql .= " '".$this->db->escape($list)."', "; + $sql .= " ".$totalizable.","; + $sql .= " ".(($default != '') ? "'".$this->db->escape($default)."'" : "null").","; + $sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").","; + $sql .= " ".$user->id.","; + $sql .= " ".$user->id.","; + $sql .= "'".$this->db->idate(dol_now())."',"; + $sql .= "'".$this->db->escape($enabled)."',"; + $sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null"); + $sql .= ")"; - $resql2=$this->db->query($sql); + $resql2 = $this->db->query($sql); if ($resql1 && $resql2) { @@ -839,11 +839,11 @@ class ExtraFields if (empty($elementtype)) return array(); - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; - if ($elementtype == 'order_supplier') $elementtype='commande_fournisseur'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; + if ($elementtype == 'order_supplier') $elementtype = 'commande_fournisseur'; - $array_name_label=array(); + $array_name_label = array(); // To avoid conflicts with external modules. TODO Remove this. if (empty($forceload) && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; @@ -871,12 +871,12 @@ class ExtraFields // We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help"; - $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later - if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element - $sql.= " ORDER BY pos"; + if ($elementtype) $sql .= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element + $sql .= " ORDER BY pos"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -888,7 +888,7 @@ class ExtraFields // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value if ($tab->fieldrequired && is_null($tab->fielddefault)) { - $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name] = $tab->type; } continue; } @@ -969,58 +969,58 @@ class ExtraFields */ public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '', $mode = 0) { - global $conf,$langs,$form; + global $conf, $langs, $form; - if (! is_object($form)) + if (!is_object($form)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $form=new Form($this->db); + $form = new Form($this->db); } - $out=''; + $out = ''; - if (! preg_match('/options_$/', $keyprefix)) // Because we work on extrafields, we add 'options_' to prefix if not already added + if (!preg_match('/options_$/', $keyprefix)) // Because we work on extrafields, we add 'options_' to prefix if not already added { $keyprefix = $keyprefix.'options_'; } - if (! empty($extrafieldsobjectkey)) + if (!empty($extrafieldsobjectkey)) { - $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; - $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; - $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; - $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; - $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; - $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; - $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); - $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); - $totalizable=$this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; - $help=$this->attributes[$extrafieldsobjectkey]['help'][$key]; - $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size = $this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default = $this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); + $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; + $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; + $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage { - $label=$this->attribute_label[$key]; - $type =$this->attribute_type[$key]; - $size =$this->attribute_size[$key]; - $elementtype=$this->attribute_elementtype[$key]; // Seems not used - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $totalizable=$this->attribute_totalizable[$key]; - $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attribute_label[$key]; + $type = $this->attribute_type[$key]; + $size = $this->attribute_size[$key]; + $elementtype = $this->attribute_elementtype[$key]; // Seems not used + $default = $this->attribute_default[$key]; + $computed = $this->attribute_computed[$key]; + $unique = $this->attribute_unique[$key]; + $required = $this->attribute_required[$key]; + $param = $this->attribute_param[$key]; + $langfile = $this->attribute_langfile[$key]; + $list = $this->attribute_list[$key]; + $totalizable = $this->attribute_totalizable[$key]; + $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } if ($computed) { - if (! preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; + if (!preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; else return ''; } @@ -1034,21 +1034,21 @@ class ExtraFields { $morecss = 'minwidth200imp'; } - elseif (in_array($type, array('int','integer','double','price'))) + elseif (in_array($type, array('int', 'integer', 'double', 'price'))) { $morecss = 'maxwidth75'; } elseif ($type == 'password') { - $morecss='maxwidth100'; + $morecss = 'maxwidth100'; } elseif ($type == 'url') { - $morecss='minwidth400'; + $morecss = 'minwidth400'; } elseif ($type == 'boolean') { - $morecss=''; + $morecss = ''; } else { @@ -1067,10 +1067,10 @@ class ExtraFields } } - if (in_array($type, array('date','datetime'))) + if (in_array($type, array('date', 'datetime'))) { - $tmp=explode(',', $size); - $newsize=$tmp[0]; + $tmp = explode(',', $size); + $newsize = $tmp[0]; $showtime = in_array($type, array('datetime')) ? 1 : 0; @@ -1080,118 +1080,118 @@ class ExtraFields // TODO Must also support $moreparam $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } - elseif (in_array($type, array('int','integer'))) + elseif (in_array($type, array('int', 'integer'))) { - $tmp=explode(',', $size); - $newsize=$tmp[0]; - $out=''; + $tmp = explode(',', $size); + $newsize = $tmp[0]; + $out = ''; } elseif (preg_match('/varchar/', $type)) { - $out=''; + $out = ''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out = ''; } elseif ($type == 'text') { - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out=$doleditor->Create(1); + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); + $out = $doleditor->Create(1); } else { - $out=''; + $out = ''; } } elseif ($type == 'html') { - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, ! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out=$doleditor->Create(1); + $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); + $out = $doleditor->Create(1); } else { - $out=''; + $out = ''; } } elseif ($type == 'boolean') { if (empty($mode)) { - $checked=''; + $checked = ''; if (!empty($value)) { - $checked=' checked value="1" '; + $checked = ' checked value="1" '; } else { - $checked=' value="1" '; + $checked = ' value="1" '; } - $out=''; + $out = ''; } else { - $out.=$form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); + $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1, false, 1); } } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value=price($value); + $value = price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out = ' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. - $value=price($value); + $value = price($value); } - $out=' '; + $out = ' '; } elseif ($type == 'select') { $out = ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; + $out .= ''; foreach ($param['options'] as $key => $val) { if ((string) $key == '') continue; list($val, $parent) = explode('|', $val); - $out.=''; + $out .= ''; } - $out.=''; + $out .= ''; } elseif ($type == 'sellist') { $out = ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { - $param_list=array_keys($param['options']); + $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $parentName=''; - $parentField=''; + $parentName = ''; + $parentField = ''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -1199,22 +1199,22 @@ class ExtraFields // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value // 5 : id category type // 6 : ids categories list separated by comma for category root - $keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid'); + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList='main.'.$InfoFieldList[2].' as rowid'; + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; } else { - $keyList=$InfoFieldList[2].' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } } - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { list($parentName, $parentField) = explode('|', $InfoFieldList[3]); - $keyList.= ', '.$parentField; + $keyList .= ', '.$parentField; } $filter_categorie = false; @@ -1232,8 +1232,8 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use curent entity filter if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { @@ -1252,24 +1252,24 @@ class ExtraFields } //We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = ' . $conf->entity; + $sqlwhere .= ' AND entity = '.$conf->entity; } $sql .= $sqlwhere; //print $sql; - $sql .= ' ORDER BY ' . implode(', ', $fields_label); + $sql .= ' ORDER BY '.implode(', ', $fields_label); - dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG); + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= ''; @@ -1285,7 +1285,7 @@ class ExtraFields if (is_array($fields_label) && count($fields_label) > 1) { $notrans = true; foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow . ' '; + $labeltoshow .= $obj->$field_toshow.' '; } } else { $labeltoshow = $obj->{$InfoFieldList[1]}; @@ -1296,10 +1296,10 @@ class ExtraFields if (!$notrans) { foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18) . ' '; + $labeltoshow = dol_trunc($translabel, 18).' '; } } - $out .= ''; + $out .= ''; } else { if (!$notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); @@ -1308,48 +1308,48 @@ class ExtraFields if (empty($labeltoshow)) $labeltoshow = '(not defined)'; if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + $parent = $parentName.':'.$obj->{$parentField}; } - $out .= ''; + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); + $out .= '>'.$labeltoshow.''; } $i++; } $this->db->free($resql); } else { - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; } } else { $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); $out .= ''; foreach ($data as $data_key => $data_value) { - $out .= ''; } } } - $out.=''; + $out .= ''; } elseif ($type == 'checkbox') { - $value_arr=explode(',', $value); - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $value_arr = explode(',', $value); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') { - $out=''; + $out = ''; foreach ($param['options'] as $keyopt => $val) { - $out.=''.$val.'
'; + $out .= ''.$val.'
'; } } elseif ($type == 'chkbxlst') @@ -1364,8 +1364,8 @@ class ExtraFields if (is_array($param['options'])) { $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $parentName=''; - $parentField=''; + $parentName = ''; + $parentField = ''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -1373,17 +1373,17 @@ class ExtraFields // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value // 5 : id category type // 6 : ids categories list separated by comma for category root - $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid'); + $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); - if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) { - list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]); - $keyList .= ', ' . $parentField; + if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) { + list ($parentName, $parentField) = explode('|', $InfoFieldList[3]); + $keyList .= ', '.$parentField; } - if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) { + if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) { if (strpos($InfoFieldList[4], 'extra.') !== false) { - $keyList = 'main.' . $InfoFieldList[2] . ' as rowid'; + $keyList = 'main.'.$InfoFieldList[2].' as rowid'; } else { - $keyList = $InfoFieldList[2] . ' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } } @@ -1402,8 +1402,8 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -1426,11 +1426,11 @@ class ExtraFields // Init des compteurs $nbPregRepl = $nbPregSel = 0; // On retire toutes les parenthèses sans = avant - $InfoFieldList[4] = preg_replace('#([^=])(\([^)^(]*(' . $word . ')[^)^(]*\))#', '$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl); + $InfoFieldList[4] = preg_replace('#([^=])(\([^)^(]*('.$word.')[^)^(]*\))#', '$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl); // On retire les espaces autour des = et parenthèses $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); // On retire toutes les parenthèses avec = avant - $InfoFieldList[4] = preg_replace('#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*(' . $word . ')[^)^(]*\)#', '$1 ', $InfoFieldList[4], -1, $nbPregSel); + $InfoFieldList[4] = preg_replace('#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.')[^)^(]*\)#', '$1 ', $InfoFieldList[4], -1, $nbPregSel); // On retire les espaces autour des = et parenthèses $InfoFieldList[4] = preg_replace('# *(=|\(|\)) *#', '$1', $InfoFieldList[4]); @@ -1439,7 +1439,7 @@ class ExtraFields } // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *(' . $word . ') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); + preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); while (!empty($matchCondition[0])) { // If the two sides differ but are not empty if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) { @@ -1448,7 +1448,7 @@ class ExtraFields } else { if (!empty($matchCondition[1])) { $boolCond = (($matchCondition[1] == "AND") ? ' AND TRUE ' : ' OR FALSE '); - $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond . $matchCondition[3], $InfoFieldList[4]); + $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]); } elseif (!empty($matchCondition[3])) { $boolCond = (($matchCondition[3] == "AND") ? ' TRUE AND ' : ' FALSE OR'); $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]); @@ -1458,7 +1458,7 @@ class ExtraFields } // Si l'on a un AND ou un OR, avant ou après - preg_match('#(AND|OR|) *(' . $word . ') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); + preg_match('#(AND|OR|) *('.$word.') *(AND|OR|)#', $InfoFieldList[4], $matchCondition); } } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); @@ -1466,23 +1466,23 @@ class ExtraFields // We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; } else { - $sqlwhere .= ' WHERE ' . $InfoFieldList[4]; + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; } } else { $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = ' . $conf->entity; + $sqlwhere .= ' AND entity = '.$conf->entity; } // $sql.=preg_replace('/^ AND /','',$sqlwhere); // print $sql; $sql .= $sqlwhere; - dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG); + dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1500,7 +1500,7 @@ class ExtraFields if (is_array($fields_label)) { $notrans = true; foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow . ' '; + $labeltoshow .= $obj->$field_toshow.' '; } } else { $labeltoshow = $obj->{$InfoFieldList[1]}; @@ -1511,9 +1511,9 @@ class ExtraFields foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel, 18) . ' '; + $labeltoshow = dol_trunc($translabel, 18).' '; } else { - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; } } @@ -1535,7 +1535,7 @@ class ExtraFields } if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + $parent = $parentName.':'.$obj->{$parentField}; } $data[$obj->rowid] = $labeltoshow; @@ -1653,70 +1653,70 @@ class ExtraFields //$value=price($value); $sizeparts = explode(",", $size); $number_decimals = $sizeparts[1]; - $value=price($value, 0, $langs, 0, 0, $number_decimals, ''); + $value = price($value, 0, $langs, 0, 0, $number_decimals, ''); } } elseif ($type == 'boolean') { - $checked=''; + $checked = ''; if (!empty($value)) { - $checked=' checked '; + $checked = ' checked '; } - $value=''; + $value = ''; } elseif ($type == 'mail') { - $value=dol_print_email($value, 0, 0, 0, 64, 1, 1); + $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'url') { - $value=dol_print_url($value, '_blank', 32, 1); + $value = dol_print_url($value, '_blank', 32, 1); } elseif ($type == 'phone') { - $value=dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); + $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'price') { - $value=price($value, 0, $langs, 0, 0, -1, $conf->currency); + $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); } elseif ($type == 'select') { - if ($langfile && $param['options'][$value]) $value=$langs->trans($param['options'][$value]); - else $value=$param['options'][$value]; + if ($langfile && $param['options'][$value]) $value = $langs->trans($param['options'][$value]); + else $value = $param['options'][$value]; } elseif ($type == 'sellist') { - $param_list=array_keys($param['options']); + $param_list = array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); - $selectkey="rowid"; - $keyList='rowid'; + $selectkey = "rowid"; + $keyList = 'rowid'; - if (count($InfoFieldList)>=3) + if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; - $keyList=$InfoFieldList[2].' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); - if(is_array($fields_label)) { - $keyList .=', '; + if (is_array($fields_label)) { + $keyList .= ', '; $keyList .= implode(', ', $fields_label); } $sql = 'SELECT '.$keyList; - $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; - if (strpos($InfoFieldList[4], 'extra')!==false) + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql.= ' as main'; + $sql .= ' as main'; } - if ($selectkey=='rowid' && empty($value)) { - $sql.= " WHERE ".$selectkey."=0"; - } elseif ($selectkey=='rowid') { - $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); - }else { - $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; + if ($selectkey == 'rowid' && empty($value)) { + $sql .= " WHERE ".$selectkey."=0"; + } elseif ($selectkey == 'rowid') { + $sql .= " WHERE ".$selectkey."=".$this->db->escape($value); + } else { + $sql .= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; } //$sql.= ' AND entity = '.$conf->entity; @@ -1725,38 +1725,38 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { - $value=''; // value was used, so now we reste it to use it to build final output + $value = ''; // value was used, so now we reste it to use it to build final output $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); - if(is_array($fields_label) && count($fields_label)>1) + if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { - $translabel=''; + $translabel = ''; if (!empty($obj->$field_toshow)) { - $translabel=$langs->trans($obj->$field_toshow); + $translabel = $langs->trans($obj->$field_toshow); } - if ($translabel!=$field_toshow) { - $value.=dol_trunc($translabel, 18).' '; - }else { - $value.=$obj->$field_toshow.' '; + if ($translabel != $field_toshow) { + $value .= dol_trunc($translabel, 18).' '; + } else { + $value .= $obj->$field_toshow.' '; } } } else { - $translabel=''; + $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { - $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->{$InfoFieldList[1]}) { - $value=dol_trunc($translabel, 18); - }else { - $value=$obj->{$InfoFieldList[1]}; + if ($translabel != $obj->{$InfoFieldList[1]}) { + $value = dol_trunc($translabel, 18); + } else { + $value = $obj->{$InfoFieldList[1]}; } } } @@ -1764,20 +1764,20 @@ class ExtraFields } elseif ($type == 'radio') { - $value=$param['options'][$value]; + $value = $param['options'][$value]; } elseif ($type == 'checkbox') { - $value_arr=explode(',', $value); - $value=''; - $toprint=array(); + $value_arr = explode(',', $value); + $value = ''; + $toprint = array(); if (is_array($value_arr)) { foreach ($value_arr as $keyval=>$valueval) { - $toprint[]='
  • '.$param['options'][$valueval].'
  • '; + $toprint[] = '
  • '.$param['options'][$valueval].'
  • '; } } - $value='
      '.implode(' ', $toprint).'
    '; + $value = '
      '.implode(' ', $toprint).'
    '; } elseif ($type == 'chkbxlst') { @@ -1791,7 +1791,7 @@ class ExtraFields if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; - $keyList = $InfoFieldList[2] . ' as rowid'; + $keyList = $InfoFieldList[2].' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); @@ -1820,53 +1820,53 @@ class ExtraFields if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { $translabel = ''; - if (! empty($obj->$field_toshow)) { + if (!empty($obj->$field_toshow)) { $translabel = $langs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { - $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; + $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $toprint[]='
  • '.$obj->$field_toshow.'
  • '; + $toprint[] = '
  • '.$obj->$field_toshow.'
  • '; } } } else { $translabel = ''; - if (! empty($obj->{$InfoFieldList[1]})) { + if (!empty($obj->{$InfoFieldList[1]})) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } if ($translabel != $obj->{$InfoFieldList[1]}) { - $toprint[]='
  • '.dol_trunc($translabel, 18).'
  • '; + $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; } else { - $toprint[]='
  • '.$obj->{$InfoFieldList[1]}.'
  • '; + $toprint[] = '
  • '.$obj->{$InfoFieldList[1]}.'
  • '; } } } } - $value='
      '.implode(' ', $toprint).'
    '; + $value = '
      '.implode(' ', $toprint).'
    '; } else { - dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); } } elseif ($type == 'link') { - $out=''; + $out = ''; // Only if something to display (perf) if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate) { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' $InfoFieldList = explode(":", $param_list[0]); - $classname=$InfoFieldList[0]; - $classpath=$InfoFieldList[1]; - if (! empty($classpath)) + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { dol_include_once($InfoFieldList[1]); if ($classname && class_exists($classname)) { $object = new $classname($this->db); $object->fetch($value); - $value=$object->getNomUrl(3); + $value = $object->getNomUrl(3); } } else @@ -1878,24 +1878,24 @@ class ExtraFields } elseif ($type == 'text') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'html') { - $value=dol_htmlentitiesbr($value); + $value = dol_htmlentitiesbr($value); } elseif ($type == 'password') { - $value=dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); + $value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1); } else { - $showsize=round($size); - if ($showsize > 48) $showsize=48; + $showsize = round($size); + if ($showsize > 48) $showsize = 48; } //print $type.'-'.$size; - $out=$value; + $out = $value; return $out; } @@ -1909,44 +1909,44 @@ class ExtraFields */ public function getAlignFlag($key, $extrafieldsobjectkey = '') { - global $conf,$langs; + global $conf, $langs; - if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - else $type=$this->attribute_type[$key]; + if (!empty($extrafieldsobjectkey)) $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + else $type = $this->attribute_type[$key]; - $align=''; + $align = ''; if ($type == 'date') { - $align="center"; + $align = "center"; } elseif ($type == 'datetime') { - $align="center"; + $align = "center"; } elseif ($type == 'int') { - $align="right"; + $align = "right"; } elseif ($type == 'double') { - $align="right"; + $align = "right"; } elseif ($type == 'boolean') { - $align="center"; + $align = "center"; } elseif ($type == 'radio') { - $align="center"; + $align = "center"; } elseif ($type == 'checkbox') { - $align="center"; + $align = "center"; } elseif ($type == 'price') { - $align="right"; + $align = "right"; } return $align; @@ -1964,8 +1964,8 @@ class ExtraFields global $langs; $out = ''; + $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); + $out .= ''; $extrafield_param = $this->attributes[$object->table_element]['param'][$key]; if (!empty($extrafield_param) && is_array($extrafield_param)) { @@ -1982,19 +1982,19 @@ class ExtraFields $out .= '\n"; } - if (! empty($conf->use_javascript_ajax) || $onlyselect) + if (!empty($conf->use_javascript_ajax) || $onlyselect) { //var_dump($selected); - if ($selected == 'done') $selected='100'; - print ''; + if ($showempty) print ''; + foreach ($listofstatus as $key => $val) { print ''; if ($key == '50' && $onlyselect == 2) @@ -140,17 +140,17 @@ class FormActions } } print ''; - if ($selected == 0 || $selected == 100) $canedit=0; + if ($selected == 0 || $selected == 100) $canedit = 0; if (empty($onlyselect)) { - print ' =0)?'':' disabled').'>'; + print ' = 0) ? '' : ' disabled').'>'; print '%'; } } else { - print ' %'; + print ' %'; } } @@ -170,79 +170,79 @@ class FormActions */ public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') { - global $langs,$conf,$user; + global $langs, $conf, $user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $sortfield='a.datep,a.id'; - $sortorder='DESC,DESC'; + $sortfield = 'a.datep,a.id'; + $sortorder = 'DESC,DESC'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); - if (! is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); $num = count($listofactions); if ($num || $forceshowtitle) { - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; - $newcardbutton=''; - if (! empty($conf->agenda->enabled)) + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) { - $newcardbutton.= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } print ''."\n"; print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); - $page=0; $param=''; + $page = 0; $param = ''; print '
    '; - print '
    '.$langs->trans("LastCustomerOrders", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''; print ''; //if($num2 > 0) print ''; //else print ''; @@ -795,7 +795,7 @@ if ($object->id > 0) $commande_static->id = $objp->cid; $commande_static->ref = $objp->ref; - $commande_static->ref_client=$objp->ref_client; + $commande_static->ref_client = $objp->ref_client; $commande_static->total_ht = $objp->total_ht; $commande_static->total_tva = $objp->total_tva; $commande_static->total_ttc = $objp->total_ttc; @@ -811,7 +811,7 @@ if ($object->id > 0) } $db->free($resql); - if ($num >0) + if ($num > 0) { print "
    '.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
    "; print ''; @@ -826,24 +826,24 @@ if ($object->id > 0) /* * Last shipments */ - if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) + if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sql = 'SELECT e.rowid as id'; - $sql.= ', e.ref'; - $sql.= ', e.date_creation'; - $sql.= ', e.fk_statut as statut'; - $sql.= ', s.nom'; - $sql.= ', s.rowid as socid'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND e.entity IN (".getEntity('expedition').")"; - $sql.= ' GROUP BY e.rowid'; - $sql.= ', e.ref'; - $sql.= ', e.date_creation'; - $sql.= ', e.fk_statut'; - $sql.= ', s.nom'; - $sql.= ', s.rowid'; - $sql.= " ORDER BY e.date_creation DESC"; + $sql .= ', e.ref'; + $sql .= ', e.date_creation'; + $sql .= ', e.fk_statut as statut'; + $sql .= ', s.nom'; + $sql .= ', s.rowid as socid'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= ' GROUP BY e.rowid'; + $sql .= ', e.ref'; + $sql .= ', e.date_creation'; + $sql .= ', e.fk_statut'; + $sql .= ', s.nom'; + $sql .= ', s.rowid'; + $sql .= " ORDER BY e.date_creation DESC"; $resql = $db->query($sql); if ($resql) @@ -856,7 +856,7 @@ if ($object->id > 0) print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Multicurrency Amount TTC - print ''; - print ''; + print ''; + print ''; print ''; } // Amount - print ''; - print ''; + print ''; + print ''; // Vat - print ''; + print ''; print ''; // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 { - print ''; - print ''; + print ''; + print ''; } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 { - print ''; - print ''; + print ''; + print ''; } // Revenue stamp @@ -456,9 +456,9 @@ if ($object->id > 0) print '
    '; + print ''; print ''; @@ -880,7 +880,7 @@ if ($object->id > 0) print ''; } - print ''; + print ''; print "\n"; $i++; } @@ -899,28 +899,28 @@ if ($object->id > 0) /* * Last linked contracts */ - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE c.fk_soc = s.rowid "; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " ORDER BY c.datec DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE c.fk_soc = s.rowid "; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $contrat=new Contrat($db); + $contrat = new Contrat($db); $num = $db->num_rows($resql); - if ($num >0) + if ($num > 0) { print '
    '; print '
    '.$langs->trans("LastSendings", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''; print ''; print '
    '.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    !!!' . $sendingstatic->LibStatut($objp->statut, 5) . ''.$sendingstatic->LibStatut($objp->statut, 5).'
    '; print ''; - print ''; print ''; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; print ''; // Currency @@ -854,9 +854,9 @@ else print ''; print ''; print ''; @@ -864,15 +864,15 @@ else // Status print ''; print ''; // Country - $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; - $selectedcode=$object->country_code; - if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; + $selectedcode = $object->country_code; + if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"]; + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; print ''; // Balance print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Tags-Categories @@ -935,13 +935,13 @@ else print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -973,7 +973,7 @@ else print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2244a73b02a..3a9db058c91 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -64,8 +64,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='b.label'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'b.label'; +if (!$sortorder) $sortorder = 'ASC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Account($db); @@ -82,14 +82,14 @@ $fieldstosearchall = array( 'b.label'=>'Label', ); -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -114,11 +114,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -126,10 +126,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_ref=''; - $search_label=''; - $search_number=''; - $search_status=''; + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; } @@ -179,7 +179,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -198,41 +198,41 @@ else dol_print_error($db); -$help_url='EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; +$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; llxHeader('', $title, $help_url); -$link=''; +$link = ''; $num_rows = count($accounts); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_ref != '') $param.='&search_ref='.$search_ref; -if ($search_label != '') $param.='&search_label='.$search_label; -if ($search_number != '') $param.='&search_number='.$search_number; -if ($search_status != '') $param.='&search_status='.$search_status; -if ($show_files) $param.='&show_files=' .$show_files; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($search_ref != '') $param .= '&search_ref='.$search_ref; +if ($search_label != '') $param .= '&search_label='.$search_label; +if ($search_number != '') $param .= '&search_number='.$search_number; +if ($search_status != '') $param .= '&search_status='.$search_status; +if ($show_files) $param .= '&show_files='.$show_files; +if ($optioncss != '') $param .= '&optioncss='.$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"), // 'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->banque->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->banque->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->banque->configurer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create'); } @@ -249,89 +249,89 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank', 0, $newcardbutton, '', $limit, 1); -$topicmail="Information"; +$topicmail = "Information"; //$modelmail="subscription"; -$objecttmp=new Account($db); +$objecttmp = new Account($db); //$trackid='sub'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
    '.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
    '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } -$moreforfilter=''; +$moreforfilter = ''; // Bank accounts -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; print '
    '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
    '; -print '
    '; + print ''; @@ -932,10 +932,10 @@ if ($object->id > 0) { $objp = $db->fetch_object($resql); - $contrat->id=$objp->id; - $contrat->ref=$objp->ref?$objp->ref:$objp->id; - $contrat->ref_customer=$objp->refcus; - $contrat->ref_supplier=$objp->refsup; + $contrat->id = $objp->id; + $contrat->ref = $objp->ref ? $objp->ref : $objp->id; + $contrat->ref_customer = $objp->refcus; + $contrat->ref_supplier = $objp->refsup; $contrat->fetch_lines(); print ''; @@ -969,19 +969,19 @@ if ($object->id > 0) /* * Last interventions */ - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " ORDER BY f.tms DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND s.rowid = ".$object->id; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " ORDER BY f.tms DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $fichinter_static=new Fichinter($db); + $fichinter_static = new Fichinter($db); $num = $db->num_rows($resql); if ($num > 0) @@ -990,7 +990,7 @@ if ($object->id > 0) print '
    '.$langs->trans("LastContracts", ($num<=$MAXLIST?"":$MAXLIST)).''; print ''; //print ''; print '
    '.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllContracts").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
    '; print ''; - print ''; - print ''; + print ''; print ''; // Show fields of bank account @@ -500,32 +500,32 @@ if ($action == 'create') } print ''; - print ''; + print ''; print ''; } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '"; print ''; - print ''; print '"; print '
    '; + print ''; print ''; @@ -1001,8 +1001,8 @@ if ($object->id > 0) { $objp = $db->fetch_object($resql); - $fichinter_static->id=$objp->id; - $fichinter_static->statut=$objp->fk_statut; + $fichinter_static->id = $objp->id; + $fichinter_static->statut = $objp->fk_statut; print ''; print ''."\n"; @@ -1030,28 +1030,28 @@ if ($object->id > 0) /* * Last invoices templates */ - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as id, f.titre as ref, f.amount'; - $sql.= ', f.total as total_ht'; - $sql.= ', f.tva as total_tva'; - $sql.= ', f.total_ttc'; - $sql.= ', f.datec as dc'; - $sql.= ', f.date_last_gen, f.date_when'; - $sql.= ', f.frequency'; - $sql.= ', f.unit_frequency'; - $sql.= ', f.suspended as suspended'; - $sql.= ', s.nom, s.rowid as socid'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; - $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; - $sql.= ' f.suspended,'; - $sql.= ' s.nom, s.rowid'; - $sql.= " ORDER BY f.date_last_gen, f.datec DESC"; + $sql .= ', f.total as total_ht'; + $sql .= ', f.tva as total_tva'; + $sql .= ', f.total_ttc'; + $sql .= ', f.datec as dc'; + $sql .= ', f.date_last_gen, f.date_when'; + $sql .= ', f.frequency'; + $sql .= ', f.unit_frequency'; + $sql .= ', f.suspended as suspended'; + $sql .= ', s.nom, s.rowid as socid'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND f.entity = ".$conf->entity; + $sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; + $sql .= ' f.suspended,'; + $sql .= ' s.nom, s.rowid'; + $sql .= " ORDER BY f.date_last_gen, f.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $invoicetemplate = new FactureRec($db); @@ -1063,7 +1063,7 @@ if ($object->id > 0) print '
    '.$langs->trans("LastInterventions", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.''; print ''; print '
    '.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    '.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.'
    '; print ''; - print ''; @@ -707,7 +707,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) // Checkbox print '' ; + print ''; print ''; @@ -719,7 +719,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; // Buttons actions - print '
    global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE)?' checked="checked"':'').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); + print '
    global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE) ? ' checked="checked"' : '').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); print '
    '; print ''; print ''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 980cf6bd8f2..23f92c773f4 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -29,19 +29,19 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","bills","categories","companies","compta")); +$langs->loadLangs(array("banks", "bills", "categories", "companies", "compta")); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); @@ -59,17 +59,17 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('bankcard','globalcard')); +$hookmanager->initHooks(array('bankcard', 'globalcard')); /* * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; if ($action == 'add') { - $error=0; + $error = 0; $db->begin(); @@ -124,26 +124,26 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation $error++; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if (! $error) + if (!$error) { $id = $object->create($user); if ($id > 0) @@ -152,19 +152,19 @@ if ($action == 'add') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$id; // Force chargement page en mode visu + $_GET["id"] = $id; // Force chargement page en mode visu - $action=''; + $action = ''; } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; // Force chargement page en mode creation + $action = 'create'; // Force chargement page en mode creation } } - if (! $error) + if (!$error) { $db->commit(); } @@ -176,7 +176,7 @@ if ($action == 'add') if ($action == 'update') { - $error=0; + $error = 0; // Update account $object = new Account($db); @@ -225,31 +225,31 @@ if ($action == 'update') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->ref)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } if (empty($object->label)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); - $action='edit'; // Force chargement page en mode creation + $action = 'edit'; // Force chargement page en mode creation $error++; } $db->begin(); - if (! $error) + if (!$error) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); } - if (! $error) + if (!$error) { $result = $object->update($user); if ($result >= 0) @@ -258,17 +258,17 @@ if ($action == 'update') $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu + $_GET["id"] = $_POST["id"]; // Force chargement page en mode visu } else { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } } - if (! $error) + if (!$error) { $db->commit(); } @@ -306,11 +306,11 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -$title = $langs->trans("FinancialAccount") . " - " . $langs->trans("Card"); +$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card"); $helpurl = ""; llxHeader("", $title, $helpurl); @@ -319,7 +319,7 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - $object=new Account($db); + $object = new Account($db); print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png'); @@ -350,7 +350,7 @@ if ($action == 'create') // Ref print '
    '; - print ''; + print ''; // Label print ''; @@ -359,15 +359,15 @@ if ($action == 'create') // Type print ''; print ''; // Currency print ''; print ''; @@ -375,17 +375,17 @@ if ($action == 'create') // Status print ''; print ''; // Country - $selectedcode=''; + $selectedcode = ''; if (isset($_POST["account_country_id"])) { - $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$object->country_code; + $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; } - elseif (empty($selectedcode)) $selectedcode=$mysoc->country_code; - $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; + $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -454,7 +454,7 @@ if ($action == 'create') // Sold print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
    '; + print ''; print ''; } @@ -1107,7 +1107,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print ''; // Payment term print ''; // Payment mode print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); $langs->load('projects'); print ''; print '"; @@ -550,36 +550,36 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE c.entity IN ('.getEntity('commande').')'; - $sql.= ' AND c.fk_soc = s.rowid'; + $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ', '.MAIN_DB_PREFIX.'commande as c'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ' WHERE c.entity IN ('.getEntity('commande').')'; + $sql .= ' AND c.fk_soc = s.rowid'; // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - if ($socid) $sql.= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql .= ' AND s.rowid = '.$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($sref) { - $sql.= " AND c.ref LIKE '%".$db->escape($sref)."%'"; + $sql .= " AND c.ref LIKE '%".$db->escape($sref)."%'"; } if ($sall) { - $sql.= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; + $sql .= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; } //Date filter - if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; + if ($date_start && $date_end) $sql .= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; + if ($date_starty && $date_endy) $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; if (!empty($sref_client)) { - $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; + $sql .= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); if ($resql) @@ -590,18 +590,18 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) $soc->fetch($socid); } $title = $langs->trans('ListOfOrders'); - $title.=' - '.$langs->trans('StatusOrderValidated').', '.$langs->trans("StatusOrderSent").', '.$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.$langs->trans("StatusOrderSent").', '.$langs->trans('StatusOrderToBill'); $num = $db->num_rows($resql); print load_fiche_titre($title); $i = 0; - $period=$html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely=$html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); + $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); + $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); - if (! empty($socid)) + if (!empty($socid)) { // Company - $companystatic->id=$socid; - $companystatic->name=$soc->name; + $companystatic->id = $socid; + $companystatic->name = $soc->name; print '

    '.$companystatic->getNomUrl(1, 'customer').'

    '; } @@ -664,8 +664,8 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; print ''; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").' '.$num.''; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").' '.$num.'
    '; print price($objp->total_ttc); @@ -1138,25 +1138,25 @@ if ($object->id > 0) /* * Last invoices */ - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.amount'; - $sql.= ', f.total as total_ht'; - $sql.= ', f.tva as total_tva'; - $sql.= ', f.total_ttc'; - $sql.= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; - $sql.= ', s.nom, s.rowid as socid'; - $sql.= ', SUM(pf.amount) as am'; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; - $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,'; - $sql.= ' s.nom, s.rowid'; - $sql.= " ORDER BY f.datef DESC, f.datec DESC"; + $sql .= ', f.total as total_ht'; + $sql .= ', f.tva as total_tva'; + $sql .= ', f.total_ttc'; + $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; + $sql .= ', s.nom, s.rowid as socid'; + $sql .= ', SUM(pf.amount) as am'; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.datef, f.datec, f.paye, f.fk_statut,'; + $sql .= ' s.nom, s.rowid'; + $sql .= " ORDER BY f.datef DESC, f.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $facturestatic = new Facture($db); @@ -1168,7 +1168,7 @@ if ($object->id > 0) print ''; print ''; - print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1260,11 +1260,11 @@ else print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); @@ -1276,43 +1276,43 @@ else // Subject print ''; - $trackid=''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. + $trackid = ''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. dol_init_file_process($upload_dir, $trackid); // Joined files - $addfileaction='addfile'; + $addfileaction = 'addfile'; print ''; print ''; @@ -1330,14 +1330,14 @@ else { // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); } if ($action == 'edithtml') { // Editor HTML source require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 465bf7dcc50..0b47d8c4aa5 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -36,7 +36,7 @@ class AdvanceTargetingMailing extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -46,12 +46,12 @@ class AdvanceTargetingMailing extends CommonObject /** * @var string ID to identify managed object */ - public $element='advtargetemailing'; + public $element = 'advtargetemailing'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='advtargetemailing'; + public $table_element = 'advtargetemailing'; /** * @var int ID @@ -64,12 +64,12 @@ class AdvanceTargetingMailing extends CommonObject public $type_element; public $filtervalue; public $fk_user_author; - public $datec=''; + public $datec = ''; public $fk_user_mod; - public $tms=''; + public $tms = ''; public $select_target_type = array(); - public $type_statuscommprospect=array(); + public $type_statuscommprospect = array(); public $thirdparty_lines; public $contact_lines; @@ -88,12 +88,12 @@ class AdvanceTargetingMailing extends CommonObject $this->select_target_type = array( '2' => $langs->trans('Contacts'), - '1' => $langs->trans('Contacts') . '+' . $langs->trans('ThirdParty'), + '1' => $langs->trans('Contacts').'+'.$langs->trans('ThirdParty'), '3' => $langs->trans('ThirdParty'), '4' => $langs->trans('ContactsWithThirdpartyFilter') ); $this->type_statuscommprospect = array( - - 1 => $langs->trans("StatusProspect-1"), + -1 => $langs->trans("StatusProspect-1"), 0 => $langs->trans("StatusProspect0"), 1 => $langs->trans("StatusProspect1"), 2 => $langs->trans("StatusProspect2"), @@ -111,50 +111,50 @@ class AdvanceTargetingMailing extends CommonObject public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; - if (isset($this->type_element)) $this->type_element=trim($this->type_element); + if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element; + if (isset($this->type_element)) $this->type_element = trim($this->type_element); - if (isset($this->name)) $this->name=trim($this->name); - if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->name)) $this->name = trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue); // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; - $sql.= "name,"; - $sql.= "entity,"; - $sql.= "fk_element,"; - $sql.= "type_element,"; - $sql.= "filtervalue,"; - $sql.= "fk_user_author,"; - $sql.= "datec,"; - $sql.= "fk_user_mod"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; - $sql.= " ".$conf->entity.","; - $sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").","; - $sql.= " ".(! isset($this->type_element)?'NULL':"'".$this->db->escape($this->type_element)."'").","; - $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " null"; - $sql.= ")"; + $sql .= "name,"; + $sql .= "entity,"; + $sql .= "fk_element,"; + $sql .= "type_element,"; + $sql .= "filtervalue,"; + $sql .= "fk_user_author,"; + $sql .= "datec,"; + $sql .= "fk_user_mod"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->name) ? 'NULL' : "'".$this->db->escape($this->name)."'").","; + $sql .= " ".$conf->entity.","; + $sql .= " ".(!isset($this->fk_element) ? 'NULL' : "'".$this->db->escape($this->fk_element)."'").","; + $sql .= " ".(!isset($this->type_element) ? 'NULL' : "'".$this->db->escape($this->type_element)."'").","; + $sql .= " ".(!isset($this->filtervalue) ? 'NULL' : "'".$this->db->escape($this->filtervalue)."'").","; + $sql .= " ".$user->id.","; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " null"; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create sql=".$sql, 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(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing"); - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -171,13 +171,13 @@ class AdvanceTargetingMailing extends CommonObject // 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 { @@ -196,30 +196,30 @@ class AdvanceTargetingMailing extends CommonObject { global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -237,7 +237,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -255,34 +255,34 @@ class AdvanceTargetingMailing extends CommonObject // phpcs:enable global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql.= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; - }else { - $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; + $sql .= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; + } else { + $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -300,7 +300,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -322,34 +322,34 @@ class AdvanceTargetingMailing extends CommonObject // phpcs:enable global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.name,"; - $sql.= " t.entity,"; - $sql.= " t.fk_element,"; - $sql.= " t.type_element,"; - $sql.= " t.filtervalue,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.datec,"; - $sql.= " t.fk_user_mod,"; - $sql.= " t.tms"; + $sql .= " t.name,"; + $sql .= " t.entity,"; + $sql .= " t.fk_element,"; + $sql .= " t.type_element,"; + $sql .= " t.filtervalue,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.datec,"; + $sql .= " t.fk_user_mod,"; + $sql .= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql.= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; - }else { - $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; + $sql .= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; + } else { + $sql .= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->name = $obj->name; $this->entity = $obj->entity; @@ -367,7 +367,7 @@ class AdvanceTargetingMailing extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); return -1; } @@ -383,13 +383,13 @@ class AdvanceTargetingMailing extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; - if (isset($this->type_element)) $this->type_element=trim($this->type_element); - if (isset($this->name)) $this->name=trim($this->name); - if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); + if (isset($this->fk_element)) $this->fk_element = (int) $this->fk_element; + if (isset($this->type_element)) $this->type_element = trim($this->type_element); + if (isset($this->name)) $this->name = trim($this->name); + if (isset($this->filtervalue)) $this->filtervalue = trim($this->filtervalue); // Check parameters // Put here code to add a control on parameters values @@ -397,21 +397,21 @@ class AdvanceTargetingMailing extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."advtargetemailing SET"; - $sql.= " name=".(isset($this->name)?"'".$this->db->escape($this->name)."'":"''").","; - $sql.= " entity=".$conf->entity.","; - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; - $sql.= " type_element=".(isset($this->type_element)?"'".$this->db->escape($this->type_element)."'":"null").","; - $sql.= " filtervalue=".(isset($this->filtervalue)?"'".$this->db->escape($this->filtervalue)."'":"null").","; - $sql.= " fk_user_mod=".$user->id; + $sql .= " name=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "''").","; + $sql .= " entity=".$conf->entity.","; + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; + $sql .= " type_element=".(isset($this->type_element) ? "'".$this->db->escape($this->type_element)."'" : "null").","; + $sql .= " filtervalue=".(isset($this->filtervalue) ? "'".$this->db->escape($this->filtervalue)."'" : "null").","; + $sql .= " fk_user_mod=".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); 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(); } //if (! $error) @@ -433,13 +433,13 @@ class AdvanceTargetingMailing 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 { @@ -458,13 +458,13 @@ class AdvanceTargetingMailing extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -478,26 +478,26 @@ class AdvanceTargetingMailing extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; 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) + 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 { @@ -516,17 +516,17 @@ class AdvanceTargetingMailing extends CommonObject */ public function savequery($user, $arrayquery) { - global $langs,$conf; + global $langs, $conf; if (!empty($arrayquery)) { - $result=$this->fetch_by_mailing($this->fk_element); - $this->filtervalue=json_encode($arrayquery); - if ($result<0) { + $result = $this->fetch_by_mailing($this->fk_element); + $this->filtervalue = json_encode($arrayquery); + if ($result < 0) { return -1; } if (!empty($this->id)) { $this->update($user); - }else { + } else { $this->create($user); } } @@ -662,7 +662,7 @@ class AdvanceTargetingMailing extends CommonObject if ($num) { - while( $i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -675,8 +675,8 @@ class AdvanceTargetingMailing extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::query_thirdparty " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::query_thirdparty ".$this->error, LOG_ERR); return -1; } } @@ -905,7 +905,7 @@ class AdvanceTargetingMailing extends CommonObject if ($num) { - while( $i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -918,8 +918,8 @@ class AdvanceTargetingMailing extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::query_contact " . $this->error, LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::query_contact ".$this->error, LOG_ERR); return -1; } } @@ -940,26 +940,26 @@ class AdvanceTargetingMailing extends CommonObject //This is a multiple value test if (preg_match('/;/', $criteria)) { - $return_sql_not_like=array(); - $return_sql_like=array(); + $return_sql_not_like = array(); + $return_sql_like = array(); - $criteria_array=explode(';', $criteria); - foreach($criteria_array as $inter_criteria) { + $criteria_array = explode(';', $criteria); + foreach ($criteria_array as $inter_criteria) { if (preg_match('/!/', $inter_criteria)) { - $return_sql_not_like[]= '('.$column_to_test.' NOT LIKE \''.str_replace('!', '', $inter_criteria).'\')'; + $return_sql_not_like[] = '('.$column_to_test.' NOT LIKE \''.str_replace('!', '', $inter_criteria).'\')'; } else { - $return_sql_like[]= '('.$column_to_test.' LIKE \''.$inter_criteria.'\')'; + $return_sql_like[] = '('.$column_to_test.' LIKE \''.$inter_criteria.'\')'; } } - if (count($return_sql_like)>0) { - $return_sql_criteria .= '(' . implode(' OR ', $return_sql_like) .')'; + if (count($return_sql_like) > 0) { + $return_sql_criteria .= '('.implode(' OR ', $return_sql_like).')'; } - if (count($return_sql_not_like)>0) { - $return_sql_criteria .= ' AND (' . implode(' AND ', $return_sql_not_like).')'; + if (count($return_sql_not_like) > 0) { + $return_sql_criteria .= ' AND ('.implode(' AND ', $return_sql_not_like).')'; } } else { - $return_sql_criteria .= $column_to_test . ' LIKE \''.$this->db->escape($criteria).'\''; + $return_sql_criteria .= $column_to_test.' LIKE \''.$this->db->escape($criteria).'\''; } $return_sql_criteria .= ')'; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 0e3d7a7725e..b38a796d3c7 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $langs->load("mails"); // Security check -$result=restrictedArea($user, 'mailing'); +$result = restrictedArea($user, 'mailing'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="m.date_creat"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "m.date_creat"; -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); -$filteremail=GETPOST('filteremail', 'alpha'); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); +$filteremail = GETPOST('filteremail', 'alpha'); $object = new Mailing($db); @@ -55,7 +55,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -69,11 +69,11 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -82,7 +82,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { /*foreach($object->fields as $key => $val) { @@ -90,13 +90,13 @@ if (empty($reshook)) }*/ $search_ref = ''; $search_all = ''; - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions @@ -121,28 +121,28 @@ $form = new Form($db); if ($filteremail) { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; - $sql.= " mc.statut as sendstatut"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql.= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; - $sql.= " AND mc.email = '".$db->escape($filteremail)."'"; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " mc.statut as sendstatut"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity; + $sql .= " AND mc.email = '".$db->escape($filteremail)."'"; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } else { $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql.= " WHERE m.entity = ".$conf->entity; - if ($search_ref) $sql.= " AND m.rowid = '".$db->escape($search_ref)."'"; - if ($search_all) $sql.= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="m.rowid"; - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; + $sql .= " WHERE m.entity = ".$conf->entity; + if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; + if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "m.rowid"; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); } //print $sql; @@ -151,19 +151,19 @@ if ($result) { $num = $db->num_rows($result); - $title=$langs->trans("ListOfEMailings"); - if ($filteremail) $title.=' ('.$langs->trans("SentTo", $filteremail).')'; + $title = $langs->trans("ListOfEMailings"); + if ($filteremail) $title .= ' ('.$langs->trans("SentTo", $filteremail).')'; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; $param = "&search_all=".urlencode($search_all); - if ($filteremail) $param.='&filteremail='.urlencode($filteremail); + if ($filteremail) $param .= '&filteremail='.urlencode($filteremail); print ''; if ($optioncss != '') print ''; @@ -178,7 +178,7 @@ if ($result) $moreforfilter = ''; print '
    '; - print '
    '; + print ''; print ''; @@ -1202,7 +1202,7 @@ if ($object->id > 0) print price($objp->total_ht); print ''; - if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) + if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) { print '
    '.$langs->trans("LastCustomersBills", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''; print ''; print '
    '.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
    '; print price($objp->total_ttc); @@ -1249,25 +1249,25 @@ if ($object->id > 0) print ''; } - if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) + if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) { $langs->load("propal"); print ''; } - if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1) + if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) { $langs->load("orders"); print ''; } - if ($user->rights->contrat->creer && $object->status==1) + if ($user->rights->contrat->creer && $object->status == 1) { $langs->load("contracts"); print ''; } - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) { $langs->load("fichinter"); print ''; @@ -1276,13 +1276,13 @@ if ($object->id > 0) // Add invoice if ($user->socid == 0) { - if (! empty($conf->deplacement->enabled) && $object->status==1) + if (!empty($conf->deplacement->enabled) && $object->status == 1) { $langs->load("trips"); print ''; } - if (! empty($conf->facture->enabled) && $object->status==1) + if (!empty($conf->facture->enabled) && $object->status == 1) { if (empty($user->rights->facture->creer)) { @@ -1310,7 +1310,7 @@ if ($object->id > 0) } // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1) + if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) { if ($user->rights->agenda->myactions->create) { @@ -1325,13 +1325,13 @@ if ($object->id > 0) print ''; - if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f4a0e61095f..a2d8c0a373b 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -23,7 +23,7 @@ * \brief Fiche mailing, onglet general */ -if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); +if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; @@ -54,26 +54,26 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('mailingcard','globalcard')); +$hookmanager->initHooks(array('mailingcard', 'globalcard')); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) -$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing'); +$object->substitutionarray = FormMail::getAvailableSubstitKey('emailing'); // Set $object->substitutionarrayfortest -$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); +$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); -$targetobject = null; // Not defined with mass emailing +$targetobject = null; // Not defined with mass emailing -$parameters=array('mode'=>'emailing'); -$substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject); +$parameters = array('mode'=>'emailing'); +$substitutionarray = FormMail::getAvailableSubstitKey('emailing', $targetobject); $object->substitutionarrayfortest = $substitutionarray; // List of sending methods -$listofmethods=array(); -$listofmethods['mail']='PHP mail function'; -$listofmethods['smtps']='SMTP/SMTPS socket library'; +$listofmethods = array(); +$listofmethods['mail'] = 'PHP mail function'; +$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; @@ -81,8 +81,8 @@ $listofmethods['smtps']='SMTP/SMTPS socket library'; * 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)) @@ -96,7 +96,7 @@ if (empty($reshook)) } else { - $result=$object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); + $result = $object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -107,7 +107,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action=''; + $action = ''; } // Action send emailing for everybody @@ -119,16 +119,16 @@ if (empty($reshook)) setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); - $action=''; + $action = ''; } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); - $action=''; + $action = ''; } else { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($object->statut == 0) { @@ -143,37 +143,37 @@ if (empty($reshook)) $replyto = $object->email_replyto; $errorsto = $object->email_errorsto; // Le message est-il en html - $msgishtml=-1; // Unknown by default - if (preg_match('/[\s\t]*/i', $message)) $msgishtml=1; + $msgishtml = -1; // Unknown by default + if (preg_match('/[\s\t]*/i', $message)) $msgishtml = 1; // Warning, we must not use begin-commit transaction here // because we want to save update for each mail sent. - $nbok=0; $nbko=0; + $nbok = 0; $nbko = 0; // On choisit les mails non deja envoyes pour ce mailing (statut=0) // ou envoyes en erreur (statut=-1) $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; - $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 + $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 dol_syslog("card.php: select targets", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); // nb of possible recipients + $num = $db->num_rows($resql); // nb of possible recipients if ($num) { dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG); - $now=dol_now(); + $now = dol_now(); // Positionne date debut envoi - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -184,8 +184,8 @@ if (empty($reshook)) while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) { // Here code is common with same loop ino mailing-send.php - $res=1; - $now=dol_now(); + $res = 1; + $now = dol_now(); $obj = $db->fetch_object($resql); @@ -193,18 +193,18 @@ if (empty($reshook)) $sendto = str_replace(',', ' ', dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... - $other=explode(';', $obj->other); - $tmpfield=explode('=', $other[0], 2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[1], 2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[2], 2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[3], 2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=', $other[4], 2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $other = explode(';', $obj->other); + $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - $targetobject = null; // Not defined with mass emailing - $parameters=array('mode'=>'emailing'); - $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; @@ -217,79 +217,79 @@ if (empty($reshook)) $substitutionarray['__OTHER3__'] = $other3; $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; - $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) - $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility + $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $onlinepaymentenabled = 0; - if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; - if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; - if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; + if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; + if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - $substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } else { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); - $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); } } /* For backward compatibility, deprecated */ - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); } //$substitutionisok=true; complete_substitutions_array($substitutionarray, $langs); - $newsubject=make_substitutions($subject, $substitutionarray); - $newmessage=make_substitutions($message, $substitutionarray); + $newsubject = make_substitutions($subject, $substitutionarray); + $newmessage = make_substitutions($message, $substitutionarray); $arr_file = array(); $arr_mime = array(); $arr_name = array(); $arr_css = array(); - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + $arr_file[] = $listofpaths[$key]['fullname']; + $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); + $arr_name[] = $listofpaths[$key]['name']; } } // Fabrication du mail - $trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid; + $trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); if ($mail->error) { - $res=0; + $res = 0; } /*if (! $substitutionisok) { @@ -300,7 +300,7 @@ if (empty($reshook)) // Send mail if ($res) { - $res=$mail->sendfile(); + $res = $mail->sendfile(); } if ($res) @@ -308,12 +308,12 @@ if (empty($reshook)) // Mail successful $nbok++; - dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG); - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -325,8 +325,8 @@ if (empty($reshook)) //Update status communication of thirdparty prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -335,8 +335,8 @@ if (empty($reshook)) $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -355,12 +355,12 @@ if (empty($reshook)) // Mail failed $nbko++; - dol_syslog("comm/mailing/card.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); + dol_syslog("comm/mailing/card.php: error for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING); - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -377,7 +377,7 @@ if (empty($reshook)) // Loop finished, set global statut of mail if ($nbko > 0) { - $statut=2; // Status 'sent partially' (because at least one error) + $statut = 2; // Status 'sent partially' (because at least one error) if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } @@ -385,20 +385,20 @@ if (empty($reshook)) { if ($nbok >= $num) { - $statut=3; // Send to everybody + $statut = 3; // Send to everybody setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } else { - $statut=2; // Status 'sent partially' (because not send to everybody) + $statut = 2; // Status 'sent partially' (because not send to everybody) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } } - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { dol_print_error($db); } @@ -416,22 +416,22 @@ if (empty($reshook)) // Action send test emailing if ($action == 'send' && empty($_POST["cancel"])) { - $error=0; + $error = 0; - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $object->sendto = $_POST["sendto"]; - if (! $object->sendto) + if (!$object->sendto) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { // Le message est-il en html - $msgishtml=-1; // Inconnu par defaut - if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml=1; + $msgishtml = -1; // Inconnu par defaut + if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml = 1; // other are set at begin of page $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; @@ -439,8 +439,8 @@ if (empty($reshook)) // Pratique les substitutions sur le sujet et message complete_substitutions_array($object->substitutionarrayfortest, $langs); - $tmpsujet=make_substitutions($object->sujet, $object->substitutionarrayfortest); - $tmpbody=make_substitutions($object->body, $object->substitutionarrayfortest); + $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); + $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); $arr_file = array(); $arr_mime = array(); @@ -448,25 +448,25 @@ if (empty($reshook)) $arr_css = array(); // Ajout CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor)?'':'#').$object->bgcolor; + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; // Attached files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + $arr_file[] = $listofpaths[$key]['fullname']; + $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); + $arr_name[] = $listofpaths[$key]['name']; } } - $trackid='emailingtest'; + $trackid = 'emailingtest'; $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing'); - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); @@ -494,13 +494,13 @@ if (empty($reshook)) $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); - if (! $object->titre) { + if (!$object->titre) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } - if (! $object->sujet) { + if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } - if (! $object->body) { + if (!$object->body) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } @@ -515,17 +515,17 @@ if (empty($reshook)) } setEventMessages($mesg, $mesgs, 'errors'); - $action="create"; + $action = "create"; } // Action update description of emailing if ($action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($action == 'settitre') $object->titre = trim(GETPOST('titre', 'alpha')); elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha')); - elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); + elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); elseif ($action == 'setemail_errorsto') { $object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha')); } elseif ($action == 'settitre' && empty($object->titre)) { @@ -534,7 +534,7 @@ if (empty($reshook)) $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); } - if (! $mesg) + if (!$mesg) { if ($object->update($user) >= 0) { @@ -545,34 +545,34 @@ if (empty($reshook)) } setEventMessages($mesg, $mesgs, 'errors'); - $action=""; + $action = ""; } /* * Add file in email form */ - if (! empty($_POST['addfile'])) + if (!empty($_POST['addfile'])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory dol_add_file_process($upload_dir, 0, 0); - $action="edit"; + $action = "edit"; } // Action remove file - if (! empty($_POST["removedfile"])) + if (!empty($_POST["removedfile"])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing - $action="edit"; + $action = "edit"; } // Action update emailing @@ -580,9 +580,9 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $isupload=0; + $isupload = 0; - if (! $isupload) + if (!$isupload) { $mesgs = array(); @@ -591,10 +591,10 @@ if (empty($reshook)) $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); - if (! $object->sujet) { + if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } - if (! $object->body) { + if (!$object->body) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } @@ -605,15 +605,15 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - $mesgs[] =$object->error; + $mesgs[] = $object->error; } setEventMessages($mesg, $mesgs, 'errors'); - $action="edit"; + $action = "edit"; } else { - $action="edit"; + $action = "edit"; } } @@ -663,10 +663,10 @@ if (empty($reshook)) { $db->begin(); - $result=$object->valid($user); + $result = $object->valid($user); if ($result > 0) { - $result=$object->reset_targets_status($user); + $result = $object->reset_targets_status($user); } if ($result > 0) @@ -692,13 +692,13 @@ if (empty($reshook)) { if ($object->delete($object->id)) { - $url= (! empty($urlfrom) ? $urlfrom : 'list.php'); + $url = (!empty($urlfrom) ? $urlfrom : 'list.php'); header("Location: ".$url); exit; } } - if (! empty($_POST["cancel"])) + if (!empty($_POST["cancel"])) { $action = ''; } @@ -712,7 +712,7 @@ if (empty($reshook)) $form = new Form($db); $htmlother = new FormOther($db); -$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; +$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader('', $langs->trans("Mailing"), $help_url, '', 0, 0, array( '/includes/ace/src/ace.js', @@ -729,14 +729,14 @@ if ($action == 'create') print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; - $availablelink=$form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); + $availablelink = $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; @@ -748,11 +748,11 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; + print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -773,7 +773,7 @@ if ($action == 'create') print '
    '; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); + $doleditor = new DolEditor('bodyemail', GETPOST('bodyemail', 'none'), '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); print '
    '; @@ -787,7 +787,7 @@ else { if ($object->id > 0) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $head = emailing_prepare_head($object); @@ -809,7 +809,7 @@ else // Confirm delete elseif ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(! empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } @@ -919,22 +919,22 @@ else print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '.$langs->trans("MailTitle").'
    '.$langs->trans("MailFrom").'
    '.$langs->trans("MailErrorsTo").'
    '.$langs->trans("MailErrorsTo").'
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:0); + $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text=''; - if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { - $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { - $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -947,7 +947,7 @@ else print '
    '; @@ -960,9 +960,9 @@ else if ($action == 'clone') { // Create an array for form - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) ); // Paiement incomplet. On demande si motif = escompte ou autre @@ -973,7 +973,7 @@ else * Boutons d'action */ - if (GETPOST('cancel', 'alpha') || $confirm=='no' || $action == '' || in_array($action, array('settodraft','valid','delete','sendall','clone','test'))) + if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { print "\n\n
    \n"; @@ -984,7 +984,7 @@ else if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer) { - if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_MAILING)) + if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { print ''.$langs->trans("EditWithEditor").''; } @@ -993,12 +993,12 @@ else print ''.$langs->trans("EditWithTextEditor").''; } - if (! empty($conf->use_javascript_ajax)) print ''.$langs->trans("EditHTMLSource").''; + if (!empty($conf->use_javascript_ajax)) print ''.$langs->trans("EditHTMLSource").''; } //print ''.$langs->trans("PreviewMailing").''; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("TestMailing").''; } @@ -1029,7 +1029,7 @@ else { print ''.$langs->trans("SendMailing").''; } - elseif (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; } @@ -1046,7 +1046,7 @@ else if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) { - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("ResetMailing").''; } @@ -1058,13 +1058,13 @@ else if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) { - if ($object->statut > 0 && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->delete)) + if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) { print ''.$langs->trans("DeleteMailing").''; } else { - print ''.$langs->trans("DeleteMailing").''; + print ''.$langs->trans("DeleteMailing").''; } } @@ -1084,25 +1084,25 @@ else $formmail = new FormMail($db); $formmail->fromname = $object->email_from; $formmail->frommail = $object->email_from; - $formmail->withsubstit=1; - $formmail->withfrom=0; - $formmail->withto=$user->email?$user->email:1; - $formmail->withtocc=0; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=0; - $formmail->withtopicreadonly=1; - $formmail->withfile=0; - $formmail->withbody=0; - $formmail->withbodyreadonly=1; - $formmail->withcancel=1; - $formmail->withdeliveryreceipt=0; + $formmail->withsubstit = 1; + $formmail->withfrom = 0; + $formmail->withto = $user->email ? $user->email : 1; + $formmail->withtocc = 0; + $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; + $formmail->withtopic = 0; + $formmail->withtopicreadonly = 1; + $formmail->withfile = 0; + $formmail->withbody = 0; + $formmail->withbodyreadonly = 1; + $formmail->withcancel = 1; + $formmail->withdeliveryreceipt = 0; // Tableau des substitutions - $formmail->substit=$object->substitutionarrayfortest; + $formmail->substit = $object->substitutionarrayfortest; // Tableau des parametres complementaires du post - $formmail->param["action"]="send"; - $formmail->param["models"]='none'; - $formmail->param["mailid"]=$object->id; - $formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id; + $formmail->param["action"] = "send"; + $formmail->param["models"] = 'none'; + $formmail->param["mailid"] = $object->id; + $formmail->param["returnurl"] = $_SERVER['PHP_SELF']."?id=".$object->id; print $formmail->get_form(); @@ -1115,11 +1115,11 @@ else $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
    '; - foreach($object->substitutionarray as $key => $val) + foreach ($object->substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
    '; + $htmltext .= $key.' = '.$langs->trans($val).'
    '; } - $htmltext.='
    '; + $htmltext .= ''; // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'helpclickable', '', 0, 2, 'emailsubstitionhelp'), 'generic'); @@ -1134,10 +1134,10 @@ else // Joined files print '
    '.$langs->trans("MailFile").''; // List of files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print '
    '; @@ -1157,13 +1157,13 @@ else print '
    '; // Message - print '
    '; + print '
    '; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { - $readonly=1; + $readonly = 1; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1, 20, '90%', $readonly); + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly); $doleditor->Create(); } else print dol_htmlentitiesbr($object->body); @@ -1181,8 +1181,8 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $morehtmlright = ''; + if ($object->statut == 2) $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -1209,22 +1209,22 @@ else print '
    '; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:0); + $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text=''; - if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { - $text.=$langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { - $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -1237,8 +1237,8 @@ else print '
    '.$langs->trans("MailTopic").'
    '.$langs->trans("MailFile").''; // List of files - $listofpaths=dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $out.= '
    '; - $out.= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; - $out.= ' '; - $out.= '
    '; + $out .= '
    '; + $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; + $out .= ' '; + $out .= '
    '; } } else { - $out.= $langs->trans("NoAttachedFiles").'
    '; + $out .= $langs->trans("NoAttachedFiles").'
    '; } // Add link to add file - $out.= ''; - $out.= ' '; - $out.= ''; + $out .= ''; + $out .= ' '; + $out .= ''; print $out; print '
    '."\n"; + print '
    '."\n"; print ''; print ''; print ''; - if (! $filteremail) print ''; + if (!$filteremail) print ''; print ''; print ''; print ''; print "\n"; @@ -202,15 +202,15 @@ if ($result) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder); - if (! $filteremail) print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder); - if (! $filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); + if (!$filteremail) print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder); + if (!$filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); else print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail?"mc.statut":"m.statut"), $param, "", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $email=new Mailing($db); + $email = new Mailing($db); while ($i < min($num, $limit)) { @@ -233,7 +233,7 @@ if ($result) print ''; // Nb of email - if (! $filteremail) + if (!$filteremail) { print ''."\n"; print '
    '; @@ -189,11 +189,11 @@ if ($result) print ''; print '     '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
    '; $nbemail = $obj->nbemail; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 14f5913c4ce..248ad8f47a0 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -62,7 +62,7 @@ if ($id > 0 || ! empty($ref)) $error++; } } -if (! $error) +if (!$error) { $object->fetch_thirdparty(); } @@ -109,7 +109,7 @@ elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } } @@ -143,7 +143,7 @@ elseif ($action == 'setaddress' && $user->rights->propale->creer) llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); -$formcompany= new FormCompany($db); +$formcompany = new FormCompany($db); $formother = new FormOther($db); if ($object->id > 0) @@ -205,10 +205,10 @@ if ($object->id > 0) // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 55a21445be2..af2e866966a 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page @@ -79,7 +79,7 @@ if ($object->id > 0) { $object->fetch_thirdparty(); $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -176,8 +176,8 @@ if ($object->id > 0) $modulepart = 'propal'; $permission = $user->rights->propal->creer; $permtoedit = $user->rights->propal->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'; } else { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index ee9d9bd9c4f..1abbeb6370c 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -51,9 +51,9 @@ $object = new Propal($db); * Actions */ -$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -65,11 +65,11 @@ llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($mesg) print $mesg; - $now=dol_now(); + $now = dol_now(); if ($object->fetch($id, $ref) > 0) { diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 97890c9d2ef..10aaf0fd2ac 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -83,7 +83,7 @@ elseif ($action == 'swapstatut' && $user->rights->commande->creer) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -124,8 +124,8 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); /* *************************************************************************** */ @@ -134,7 +134,7 @@ $userstatic=new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $langs->trans("OrderCard"); @@ -200,10 +200,10 @@ if ($id > 0 || ! empty($ref)) print '
    '; // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 565583e1fae..8d5afb985a3 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -31,9 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page @@ -49,7 +49,7 @@ if ($user->socid) { $socid = $user->socid; } -$result=restrictedArea($user, 'commande', $id, ''); +$result = restrictedArea($user, 'commande', $id, ''); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); @@ -76,10 +76,10 @@ $object = new Commande($db); if ($object->fetch($id)) { $object->fetch_thirdparty(); - $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); } -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -90,7 +90,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { @@ -179,8 +179,8 @@ if ($id > 0 || ! empty($ref)) $modulepart = 'commande'; $permission = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer; - $param = '&id=' . $object->id.'&entity=' . (! empty($object->entity)?$object->entity:$conf->entity); - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity); + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 4ca81f77771..d509d3711b2 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -27,8 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } if (!$user->rights->commande->lire) accessforbidden(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 5b8fe052b06..3c6b1c37de3 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -71,7 +71,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients| $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); @@ -134,7 +134,7 @@ if ($id > 0 || ! empty($ref)) print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print ''; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 4cc5ce532e4..20014e58767 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -36,50 +36,50 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array("orders", "deliveries", "companies")); -if (! $user->rights->facture->creer) +if (!$user->rights->facture->creer) accessforbidden(); -$id = (GETPOST('id')?GETPOST('id', 'int'):GETPOST("facid", "int")); // For backward compatibility +$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST("facid", "int")); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $sref = GETPOST('sref', 'alpha'); -$sref_client = GETPOST('sref_client', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$socid = GETPOST('socid', 'int'); -$selected = GETPOST('orders_to_invoice'); +$sref_client = GETPOST('sref_client', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$selected = GETPOST('orders_to_invoice'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$viewstatut = GETPOST('viewstatut', 'alpha'); +$viewstatut = GETPOST('viewstatut', 'alpha'); $error = 0; -if (! $sortfield) $sortfield='c.rowid'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.rowid'; +if (!$sortorder) $sortorder = 'DESC'; $now = dol_now(); -$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server +$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server $date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); -$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server +$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]); $extrafields = new ExtraFields($db); -$object=new Facture($db); +$object = new Facture($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); if ($action == 'create') { - if (! is_array($selected)) + if (!is_array($selected)) { $error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); @@ -93,7 +93,7 @@ if ($action == 'create') // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); +$hookmanager = new HookManager($db); $hookmanager->initHooks(array('orderstoinvoice')); @@ -107,7 +107,7 @@ if (($action == 'create' || $action == 'add') && !$error) require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; - if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('bills'); $langs->load('products'); @@ -118,8 +118,8 @@ if (($action == 'create' || $action == 'add') && !$error) $n = count($orders_id); $i = 0; - $originid=$orders_id[0]; - $_GET['originid']=$orders_id[0]; + $originid = $orders_id[0]; + $_GET['originid'] = $orders_id[0]; } if (isset($_POST['orders_to_invoice'])) { @@ -189,23 +189,23 @@ if (($action == 'create' || $action == 'add') && !$error) $id = $object->create($user); $object->fetch_thirdparty(); - if ($id>0) + if ($id > 0) { - foreach($orders_id as $origin => $origin_id) + foreach ($orders_id as $origin => $origin_id) { - $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); + $origin_id = (!empty($origin_id) ? $origin_id : $object->origin_id); $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $origin_id; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $origin_id; + $sql .= ", '".$object->origin."'"; + $sql .= ", ".$id; + $sql .= ", '".$object->element."'"; + $sql .= ")"; if ($db->query($sql)) { @@ -222,7 +222,7 @@ if (($action == 'create' || $action == 'add') && !$error) include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $objectsrc = new Commande($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$objectsrc->fetch($orders_id[$ii]); + $result = $objectsrc->fetch($orders_id[$ii]); if ($result > 0) { if ($closeOrders) @@ -236,26 +236,26 @@ if (($action == 'create' || $action == 'add') && !$error) $objectsrc->fetch_lines(); $lines = $objectsrc->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -268,17 +268,17 @@ if (($action == 'create' || $action == 'add') && !$error) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -320,11 +320,11 @@ if (($action == 'create' || $action == 'add') && !$error) ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -354,7 +354,7 @@ if (($action == 'create' || $action == 'add') && !$error) } // End of object creation, we show it - if ($id > 0 && ! $error) + if ($id > 0 && !$error) { $db->commit(); header('Location: '.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$id); @@ -363,9 +363,9 @@ if (($action == 'create' || $action == 'add') && !$error) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -385,27 +385,27 @@ $companystatic = new Societe($db); // Mode creation if ($action == 'create' && !$error) { - $facturestatic=new Facture($db); + $facturestatic = new Facture($db); llxHeader(); print load_fiche_titre($langs->trans('NewBill')); $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); + if ($socid) $res = $soc->fetch($socid); if ($res) { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; - $remise_percent = $soc->remise_percent; + $remise_percent = $soc->remise_percent; } - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $absolute_discount=$soc->getAvailableDiscounts(); + $absolute_discount = $soc->getAvailableDiscounts(); print ''; print ''; print ''; - print '' ."\n"; + print ''."\n"; print ''; print ''; print ''; @@ -433,9 +433,9 @@ if ($action == 'create' && !$error) // Standard invoice print '
    '; - print ''; + print ''; print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); + $desc = $html->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); print $desc; print '
    '; @@ -446,16 +446,16 @@ if ($action == 'create' && !$error) print '
    '.$langs->trans('PaymentConditionsShort').''; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id'); + $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
    '.$langs->trans('PaymentMode').''; - $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id'); + $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
    '.$langs->trans('Project').''; @@ -468,7 +468,7 @@ if ($action == 'create' && !$error) $listoforders = array(); foreach ($selected as $sel) { - $result=$objectsrc->fetch($sel); + $result = $objectsrc->fetch($sel); if ($result > 0) { $listoforders[] = $objectsrc->ref; @@ -476,12 +476,12 @@ if ($action == 'create' && !$error) } // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $object=new Facture($db); + $object = new Facture($db); print $object->showOptionals($extrafields, 'edit'); } @@ -489,7 +489,7 @@ if ($action == 'create' && !$error) print '
    '.$langs->trans('Model').''; include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $liste=ModelePDFFactures::liste_modeles($db); + $liste = ModelePDFFactures::liste_modeles($db); print $html->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); print "
    '; - $generic_commande->id=$objp->rowid; - $generic_commande->ref=$objp->ref; + $generic_commande->id = $objp->rowid; + $generic_commande->ref = $objp->ref; $generic_commande->statut = $objp->fk_statut; $generic_commande->date_commande = $db->jdate($objp->date_commande); $generic_commande->date_livraison = $db->jdate($objp->date_livraison); @@ -682,9 +682,9 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; - $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->commande->multidir_output[$objp->entity] . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; + $filename = dol_sanitizeFileName($objp->ref); + $filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
    '; print '
    '; print ''; - print '
    '.$langs->trans("Ref").'ref).'" maxlength="12" autofocus>
    ref).'" maxlength="12" autofocus>
    '.$langs->trans("LabelBankCashAccount").'
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT, "type"); + $formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type"); print '
    '.$langs->trans("Currency").''; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int')!=''?GETPOST("clos", 'int'):$object->clos)); + print $form->selectarray("clos", $object->status, (GETPOST("clos", 'int') != '' ?GETPOST("clos", 'int') : $object->clos)); print '
    '.$langs->trans("BankAccountCountry").''; @@ -397,7 +397,7 @@ if ($action == 'create') print '
    '.$langs->trans('State').''; if ($selectedcode) { - $formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'', $selectedcode, 'account_state_id'); + $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); } else { @@ -433,13 +433,13 @@ if ($action == 'create') print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '90%'); $doleditor->Create(); print '
    '.$langs->trans("InitialBankBalance").'solde)).'">
    solde)).'">
    '.$langs->trans("Date").''; @@ -462,10 +462,10 @@ if ($action == 'create') print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '; print '
    '; @@ -476,7 +476,7 @@ if ($action == 'create') // If bank account print '
    '.$langs->trans("BankName").'
    '.$langs->trans($val).'
    '.$langs->trans($ibankey).'
    '.$langs->trans($bickey).'
    '.$langs->trans("BankAccountDomiciliation").''; print "
    '.$langs->trans("BankAccountOwner").''; + print ''; print '
    '.$langs->trans("BankAccountOwnerAddress").''; print "
    '; @@ -534,10 +534,10 @@ if ($action == 'create') print ''; // Accountancy code - $fieldrequired=''; - if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired '; + $fieldrequired = ''; + if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired = 'fieldrequired '; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; - print ''; + print ''; } // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; print ''; // Accountancy journal - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print '
    '.$langs->trans("AccountancyCode").''; @@ -547,11 +547,11 @@ if ($action == 'create') else { print '
    '.$langs->trans("AccountancyCode").'account_number).'">
    account_number).'">
    '.$langs->trans("AccountancyJournal").''; @@ -564,9 +564,9 @@ if ($action == 'create') dol_fiche_end(); print '
    '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
    '; print ''; @@ -588,11 +588,11 @@ else if ($_GET["ref"]) { $object->fetch(0, $_GET["ref"]); - $_GET["id"]=$object->id; + $_GET["id"] = $object->id; } // Show tabs - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); $formconfirm = ''; @@ -608,7 +608,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; + $morehtmlref = ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -648,7 +648,7 @@ else // Accountancy code print '
    '.$langs->trans("AccountancyCode").''; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_number, 1); @@ -659,7 +659,7 @@ else print '
    '.$langs->trans("AccountancyJournal").''; @@ -675,7 +675,7 @@ else // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; @@ -725,13 +725,13 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; print '
    '.$langs->trans($ibankey).''.$object->iban.' '; - if (! empty($object->iban)) { - if (! checkIbanForAccount($object)) { + if (!empty($object->iban)) { + if (!checkIbanForAccount($object)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'info'); @@ -741,8 +741,8 @@ else print '
    '.$langs->trans($bickey).''.$object->bic.' '; - if (! empty($object->bic)) { - if (! checkSwiftForAccount($object)) { + if (!empty($object->bic)) { + if (!checkSwiftForAccount($object)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'info'); @@ -783,7 +783,7 @@ else print 'id.'">'.$langs->trans("Modify").''; } - $canbedeleted=$object->can_be_deleted(); // Renvoi vrai si compte sans mouvements + $canbedeleted = $object->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print 'id.'">'.$langs->trans("Delete").''; @@ -837,16 +837,16 @@ else // Ref print '
    '.$langs->trans("Ref").'ref).'">
    ref).'">
    '.$langs->trans("Label").'label).'">
    label).'">
    '.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type), "type"); + $formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type"); print '
    '; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; + print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
    '.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos)); + print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos)); print '
    '.$langs->trans("Country").''; @@ -884,7 +884,7 @@ else print '
    '.$langs->trans('State').''; if ($selectedcode) { - print $formcompany->select_state(isset($_POST["account_state_id"])?$_POST["account_state_id"]:$object->state_id, $selectedcode, 'account_state_id'); + print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); } else { @@ -895,22 +895,22 @@ else // Conciliable print '
    '.$langs->trans("Conciliable").''; - $conciliate=$object->canBeConciliated(); + $conciliate = $object->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; elseif ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print ' 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation"); + else print ' 0) ? '' : ' checked="checked"').'"> '.$langs->trans("DisableConciliation"); print '
    '.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
    min_allowed).'">
    '.$langs->trans("BalanceMinimalDesired").'min_desired).'">
    min_desired).'">
    '.$langs->trans("Web").'url).'">'; + print 'url).'">'; print '
    '; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment', (GETPOST("account_comment")?GETPOST("account_comment"):$object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); + $doleditor = new DolEditor('account_comment', (GETPOST("account_comment") ?GETPOST("account_comment") : $object->comment), '', 90, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '95%'); $doleditor->Create(); print '
    '.$langs->trans("AccountancyJournal").''; @@ -1022,8 +1022,8 @@ else } $ibankey = FormBank::getIBANLabel($object); - $bickey="BICNumber"; - if ($object->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($object->getCountryCode() == 'IN') $bickey = "SWIFT"; // IBAN print '
    '.$langs->trans($ibankey).'
    '."\n"; +print '
    '."\n"; print ''; // Ref -if (! empty($arrayfields['b.ref']['checked'])) +if (!empty($arrayfields['b.ref']['checked'])) { print ''; } // Label -if (! empty($arrayfields['b.label']['checked'])) +if (!empty($arrayfields['b.label']['checked'])) { print ''; } // Account type -if (! empty($arrayfields['accountype']['checked'])) +if (!empty($arrayfields['accountype']['checked'])) { print ''; } // Bank number -if (! empty($arrayfields['b.number']['checked'])) +if (!empty($arrayfields['b.number']['checked'])) { print ''; } // Account number -if (! empty($arrayfields['b.account_number']['checked'])) +if (!empty($arrayfields['b.account_number']['checked'])) { print ''; } // Accountancy journal -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; } // Transactions to reconcile -if (! empty($arrayfields['toreconcile']['checked'])) +if (!empty($arrayfields['toreconcile']['checked'])) { print ''; } // Currency -if (! empty($arrayfields['b.currency_code']['checked'])) +if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; @@ -340,26 +340,26 @@ if (! empty($arrayfields['b.currency_code']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['b.datec']['checked'])) +if (!empty($arrayfields['b.datec']['checked'])) { print ''; } // Date modification -if (! empty($arrayfields['b.tms']['checked'])) +if (!empty($arrayfields['b.tms']['checked'])) { print ''; } // Status -if (! empty($arrayfields['b.clos']['checked'])) +if (!empty($arrayfields['b.clos']['checked'])) { print ''; } // Balance -if (! empty($arrayfields['balance']['checked'])) +if (!empty($arrayfields['balance']['checked'])) { print ''; } // Action column print ''; print ''; // Fields title print ''; -if (! empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['b.ref']['checked'])) print_liste_field_titre($arrayfields['b.ref']['label'], $_SERVER["PHP_SELF"], 'b.ref', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER["PHP_SELF"], 'b.label', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'], $_SERVER["PHP_SELF"], 'b.number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'], $_SERVER["PHP_SELF"], 'b.account_number', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'], $_SERVER["PHP_SELF"], 'b.fk_accountancy_journal', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'], $_SERVER["PHP_SELF"], 'b.currency_code', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$total = array(); $found = 0; $i=0; $lastcurrencycode=''; +$total = array(); $found = 0; $i = 0; $lastcurrencycode = ''; foreach ($accounts as $key=>$type) { @@ -488,26 +488,26 @@ foreach ($accounts as $key=>$type) print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Currency - if (! empty($arrayfields['b.currency_code']['checked'])) + if (!empty($arrayfields['b.currency_code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Transactions to reconcile - if (! empty($arrayfields['toreconcile']['checked'])) + if (!empty($arrayfields['toreconcile']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -586,10 +586,10 @@ foreach ($accounts as $key=>$type) } // If no record found -if (! $found) +if (!$found) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 5e7904ad7d6..c80a0cd0ab8 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -85,39 +85,39 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/compta/bank/various_payment/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1); header("Location: ".$urltogo); exit; } - if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id, $ref); - $action=''; + if ($id > 0 || !empty($ref)) $ret = $object->fetch($id, $ref); + $action = ''; } if ($action == 'add') { - $error=0; + $error = 0; - $datep=dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); - $datev=dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); - if (empty($datev)) $datev=$datep; + $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); + $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); + if (empty($datev)) $datev = $datep; - $object->ref=''; // TODO - $object->accountid=GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount", 'alpha')); - $object->label=GETPOST("label", 'none'); - $object->note=GETPOST("note", 'none'); - $object->type_payment=GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment", 'alpha'); - $object->fk_user_author=$user->id; - $object->category_transaction=GETPOST("category_transaction", 'alpha'); + $object->ref = ''; // TODO + $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount", 'alpha')); + $object->label = GETPOST("label", 'none'); + $object->note = GETPOST("note", 'none'); + $object->type_payment = GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment = GETPOST("num_payment", 'alpha'); + $object->fk_user_author = $user->id; + $object->category_transaction = GETPOST("category_transaction", 'alpha'); - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account=GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; + $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; + $object->subledger_account = GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""; - $object->sens=GETPOST('sens'); - $object->fk_project= GETPOST('fk_project', 'int'); + $object->sens = GETPOST('sens'); + $object->fk_project = GETPOST('fk_project', 'int'); if (empty($datep) || empty($datev)) { @@ -137,29 +137,29 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); $error++; } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + if (!empty($conf->banque->enabled) && !$object->accountid > 0) { $langs->load('errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); $error++; } // TODO Remove this and allow instead to edit a various payment to enter accounting code - if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + if (!empty($conf->accounting->enabled) && !$object->accountancy_code) { $langs->load('errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); - $ret=$object->create($user); + $ret = $object->create($user); if ($ret > 0) { $db->commit(); - $urltogo=($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); + $urltogo = ($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php'); header("Location: ".$urltogo); exit; } @@ -167,29 +167,29 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; + $action = "create"; } } - $action='create'; + $action = 'create'; } if ($action == 'delete') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { $db->begin(); - $ret=$object->delete($user); + $ret = $object->delete($user); if ($ret > 0) { if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); + if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) @@ -200,7 +200,7 @@ if (empty($reshook)) } else { - $object->error=$accountline->error; + $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -226,8 +226,8 @@ if (empty($reshook)) llxHeader("", $langs->trans("VariousPayment")); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if ($id) { @@ -271,25 +271,25 @@ if ($action == 'create') // Date payment print ''; // Date value for bank print ''; // Label print ''; // Sens print ''; @@ -300,11 +300,11 @@ if ($action == 'create') print ''; // Bank - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; } @@ -315,7 +315,7 @@ if ($action == 'create') print ''; // Number - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Number print ''; } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -355,7 +355,7 @@ if ($action == 'create') } // Accountancy account - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''; @@ -371,11 +371,11 @@ if ($action == 'create') } // Subledger account - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print ''; print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -519,8 +519,8 @@ if ($id) } // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $array=array( + $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); @@ -367,42 +367,42 @@ if (! empty($arrayfields['b.clos']['checked'])) print ''; -$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
    '; print $objecttmp->currency_code; print ''; if ($objecttmp->rappro) { - $result=$objecttmp->load_board($user, $objecttmp->id); - if ($result<0) { + $result = $objecttmp->load_board($user, $objecttmp->id); + if ($result < 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); } else { print ''.$result->nbtodo.''; @@ -571,12 +571,12 @@ foreach ($accounts as $key=>$type) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($objecttmp->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; + print ''; } print '
    '.$langs->trans("NoRecordFound").'
    '; print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).''; - print $form->selectDate((empty($datep)?-1:$datep), "datep", '', '', '', 'add', 1, 1); + print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1); print '
    '; print $form->editfieldkey('DateValue', 'datev', '', $object, 0).''; - print $form->selectDate((empty($datev)?-1:$datev), "datev", '', '', '', 'add', 1, 1); + print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1); print '
    '; print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print '
    '; print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).''; - $sensarray=array( '0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); print $form->selectarray('sens', $sensarray, $sens); print '
    '; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).''; - $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant + $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant print '
    '.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); + $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); print '
    '.$langs->trans("AccountAccounting").'
    '.$langs->trans("SubledgerAccount").''; - if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); } @@ -484,7 +484,7 @@ if ($id) print '
    '; print $langs->trans("AccountAccounting"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code, 1); @@ -502,11 +502,11 @@ if ($id) print $object->subledger_account; print '
    '; @@ -542,7 +542,7 @@ if ($id) // Delete if (empty($object->rappro)) { - if (! empty($user->rights->banque->modifier)) + if (!empty($user->rights->banque->modifier)) { print ''; } diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 7070946e2c7..6e8fb2a65ea 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -50,22 +50,22 @@ 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"; $object = new PaymentVarious($db); $object->fetch($id, $ref); $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id); -$modulepart='banque'; +$modulepart = 'banque'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -125,11 +125,11 @@ if ($object->id) print '
    '; // 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']; } print ''; @@ -146,8 +146,8 @@ if ($object->id) $modulepart = 'banque'; $permission = $user->rights->banque->modifier; - $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'; } else { diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 602cd9142cf..ef88c586ede 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -31,20 +31,20 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->loadLangs(array("install","cashdesk","admin","banks")); +$langs->loadLangs(array("install", "cashdesk", "admin", "banks")); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $categid = GETPOST('categid'); $label = GETPOST("label"); -$now=dol_now(); -$syear = (GETPOSTISSET('closeyear')?GETPOST('closeyear', 'int'):dol_print_date($now, "%Y")); -$smonth = (GETPOSTISSET('closemonth')?GETPOST('closemonth', 'int'):dol_print_date($now, "%m")); -$sday = (GETPOSTISSET('closeday')?GETPOST('closeday', 'int'):dol_print_date($now, "%d")); +$now = dol_now(); +$syear = (GETPOSTISSET('closeyear') ?GETPOST('closeyear', 'int') : dol_print_date($now, "%Y")); +$smonth = (GETPOSTISSET('closemonth') ?GETPOST('closemonth', 'int') : dol_print_date($now, "%m")); +$sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($now, "%d")); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -52,30 +52,30 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='rowid'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'rowid'; +if (!$sortorder) $sortorder = 'ASC'; // Security check -if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use) +if (!$user->rights->cashdesk->use && !$user->rights->takepos->use) { accessforbidden(); } -$arrayofpaymentmode=array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); +$arrayofpaymentmode = array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); -$arrayofposavailable=array(); -if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)'; -if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; +$arrayofposavailable = array(); +if (!empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk'] = $langs->trans('CashDesk').' (cashdesk)'; +if (!empty($conf->takepos->enabled)) $arrayofposavailable['takepos'] = $langs->trans('TakePOS').' (takepos)'; // TODO Add hook here to allow other POS to add themself -$object= new CashControl($db); +$object = new CashControl($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('cashcontrolcard','globalcard')); +$hookmanager->initHooks(array('cashcontrolcard', 'globalcard')); /* @@ -86,7 +86,7 @@ $permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use) $permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); -$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record +$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH1)) { @@ -99,70 +99,70 @@ if (GETPOST('cancel', 'alpha')) $action = 'create'; } -if ($action=="start") +if ($action == "start") { - $error=0; - if (! GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') + $error = 0; + if (!GETPOST('posmodule', 'alpha') || GETPOST('posmodule', 'alpha') == '-1') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Module")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if (GETPOST('posnumber', 'alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CashDesk")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') + if (!GETPOST('closeyear', 'alpha') || GETPOST('closeyear', 'alpha') == '-1') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } } -elseif ($action=="add") +elseif ($action == "add") { if (GETPOST('opening', 'alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors'); - $action='start'; + $action = 'start'; $error++; } - $error=0; - foreach($arrayofpaymentmode as $key=>$val) + $error = 0; + foreach ($arrayofpaymentmode as $key=>$val) { $object->$key = price2num(GETPOST($key.'_amount', 'alpha')); } - if (! $error) + if (!$error) { $object->day_close = GETPOST('closeday', 'int'); $object->month_close = GETPOST('closemonth', 'int'); $object->year_close = GETPOST('closeyear', 'int'); - $object->opening=price2num(GETPOST('opening', 'alpha')); - $object->posmodule=GETPOST('posmodule', 'alpha'); - $object->posnumber=GETPOST('posnumber', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->posnumber = GETPOST('posnumber', 'alpha'); $db->begin(); - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { $db->commit(); - $action="view"; + $action = "view"; } else { $db->rollback; - $action="view"; + $action = "view"; } } } -if ($action=="close") +if ($action == "close") { $object->fetch($id); @@ -176,21 +176,21 @@ if ($action=="close") setEventMessages($langs->trans("CashFenceDone"), null); } - $action="view"; + $action = "view"; } // Action to delete -if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +if ($action == 'confirm_delete' && !empty($permissiontodelete)) { $object->fetch($id); - if (! ($object->id > 0)) + if (!($object->id > 0)) { dol_print_error('', 'Error, object must be fetched before being deleted'); exit; } - $result=$object->delete($user); + $result = $object->delete($user); //var_dump($result); if ($result > 0) { @@ -201,7 +201,7 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } else { - if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); else setEventMessages($object->error, null, 'errors'); } } @@ -211,15 +211,15 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) * View */ -$form=new Form($db); +$form = new Form($db); -if ($action=="create" || $action=="start") +if ($action == "create" || $action == "start") { llxHeader(); - $initialbalanceforterminal=array(); - $theoricalamountforterminal=array(); - $theoricalnbofinvoiceforterminal=array(); + $initialbalanceforterminal = array(); + $theoricalamountforterminal = array(); + $theoricalnbofinvoiceforterminal = array(); if (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { @@ -227,16 +227,16 @@ if ($action=="create" || $action=="start") $terminalid = GETPOST('posnumber', 'alpha'); $terminaltouse = $terminalid; - if ($terminaltouse == '1' && $posmodule=='cashdesk') $terminaltouse = ''; + if ($terminaltouse == '1' && $posmodule == 'cashdesk') $terminaltouse = ''; - if ($posmodule=='cashdesk' && $terminaltouse != '' && $terminaltouse != '1') { + if ($posmodule == 'cashdesk' && $terminaltouse != '' && $terminaltouse != '1') { $terminaltouse = ''; setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors'); $error++; } // Calculate $initialbalanceforterminal for terminal 0 - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { if ($key != 'cash') { @@ -245,18 +245,18 @@ if ($action=="create" || $action=="start") } // Get the bank account dedicated to this point of sale module/terminal - $vartouse='CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; - $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) + $vartouse = 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; + $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) // Hook to get the good bank id according to posmodule and posnumber. // @TODO add hook here if ($bankid > 0) { $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$bankid; - if ($syear && ! $smonth) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql.= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); @@ -275,28 +275,28 @@ if ($action=="create" || $action=="start") } // Calculate $theoricalamountforterminal for terminal 0 - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { /*$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; $sql.= " WHERE fk_account = ".$bankid;*/ $sql = "SELECT SUM(pf.amount) as total, COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; - $sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; - $sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; - $sql.= " AND f.pos_source = '".$db->escape($terminalid)."'"; - $sql.= " AND f.paye = 1"; - $sql.= " AND p.entity IN (".getEntity('facture').")"; - if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; - elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; - elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; + $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; + $sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; + $sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; + $sql .= " AND f.paye = 1"; + $sql .= " AND p.entity IN (".getEntity('facture').")"; + if ($key == 'cash') $sql .= " AND cp.code = 'LIQ'"; + elseif ($key == 'cheque') $sql .= " AND cp.code = 'CHQ'"; + elseif ($key == 'card') $sql .= " AND cp.code = 'CB'"; else { dol_print_error('Value for key = '.$key.' not supported'); exit; } - if ($syear && ! $smonth) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; - elseif ($syear && $smonth && ! $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; + if ($syear && !$smonth) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); @@ -337,53 +337,53 @@ if ($action=="create" || $action=="start") print ''; print "\n"; - $disabled=0; - $prefix='close'; + $disabled = 0; + $prefix = 'close'; print ''; - print ''; + print ''; print ''; // Year print ''; // Month print ''; // Day print ''; // Button Start @@ -425,10 +425,10 @@ if ($action=="create" || $action=="start") print ''; - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -442,10 +442,10 @@ if ($action=="create" || $action=="start") print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -461,10 +461,10 @@ if ($action=="create" || $action=="start") print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; @@ -477,14 +477,14 @@ if ($action=="create" || $action=="start") print ''; // Initial amount print ''; // Amount per payment type - $i=0; - foreach($arrayofpaymentmode as $key => $val) + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) { - print ''; $i++; } @@ -500,23 +500,23 @@ if ($action=="create" || $action=="start") print ''; } -if (empty($action) || $action=="view") +if (empty($action) || $action == "view") { $object->fetch($id); llxHeader('', $langs->trans("CashControl")); - $head=array(); + $head = array(); $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; $head[0][1] = $langs->trans("Card"); $head[0][2] = 'cashcontrol'; dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'cashcontrol'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; - $morehtmlref.='
    '; + $morehtmlref = '
    '; + $morehtmlref .= '
    '; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); @@ -563,7 +563,7 @@ if (empty($action) || $action=="view") print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - foreach($arrayofpaymentmode as $key => $val) + foreach ($arrayofpaymentmode as $key => $val) { print '"; print "\n"; @@ -671,8 +671,8 @@ if ($resql) } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index ff71b1ff9af..d211c04d375 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -64,13 +64,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Notes'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object = new Facture($db); $object->fetch($id, $ref); @@ -85,50 +85,50 @@ if ($id > 0 || ! empty($ref)) // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // 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->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; 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 .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); @@ -136,7 +136,7 @@ if ($id > 0 || ! empty($ref)) print '
    '; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index e0569878b57..f1cbb613b18 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } if (!$user->rights->facture->lire) accessforbidden(); @@ -95,7 +95,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action=''; + $action = ''; } if ($action == "delete") @@ -117,9 +117,9 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('StandingOrders'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -135,7 +135,7 @@ if ($object->id > 0) { $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; @@ -146,10 +146,10 @@ if ($object->id > 0) //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if ($object->paye) $resteapayer=0; - $resteapayeraffiche=$resteapayer; + if ($object->paye) $resteapayer = 0; + $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -157,10 +157,10 @@ if ($object->id > 0) $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - $absolute_discount=$object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote=$object->thirdparty->getAvailableDiscounts('', $filtercreditnote); - $absolute_discount=price2num($absolute_discount, 'MT'); - $absolute_creditnote=price2num($absolute_creditnote, 'MT'); + $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); $author = new User($db); if ($object->user_author) @@ -233,27 +233,27 @@ if ($object->id > 0) print $object->getLibType(); if ($object->type == Facture::TYPE_REPLACEMENT) { - $facreplaced=new Facture($db); + $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE) { - $facusing=new Facture($db); + $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } - $facidavoir=$object->getListIdAvoirFromInvoice(); + $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) + $i = 0; + foreach ($facidavoir as $id) { - if ($i==0) print ' '; + if ($i == 0) print ' '; else print ','; - $facavoir=new Facture($db); + $facavoir = new Facture($db); $facavoir->fetch($id); print $facavoir->getNomUrl(1); } @@ -274,7 +274,7 @@ if ($object->id > 0) $thirdparty = $object->thirdparty; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?facid=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); $cannotApplyDiscount = 1; include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; @@ -285,7 +285,7 @@ if ($object->id > 0) print '
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable)>1?1:0)).''.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - $array=array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); - $selectedposnumber=0; $showempty=1; + $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); + $selectedposnumber = 0; $showempty = 1; if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') { - $selectedposnumber=1; $showempty=0; + $selectedposnumber = 1; $showempty = 0; } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber')?GETPOST('posnumber', 'int'):$selectedposnumber, $showempty); + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); //print ''; print ''; - $retstring=''; - for ($year = $syear - 10; $year < $syear + 10 ; $year++) + $retstring = ''; + for ($year = $syear - 10; $year < $syear + 10; $year++) { - $retstring.=''; + $retstring .= ''; } - $retstring.="\n"; + $retstring .= "\n"; print $retstring; print ''; - $retstring=''; - $retstring.=''; - for ($month = 1 ; $month <= 12 ; $month++) + $retstring = ''; + $retstring .= ''; + for ($month = 1; $month <= 12; $month++) { - $retstring.='"; + $retstring .= '"; } - $retstring.=""; + $retstring .= ""; print $retstring; print ''; - $retstring=''; - $retstring.=''; - for ($day = 1 ; $day <= 31; $day++) + $retstring = ''; + $retstring .= ''; + for ($day = 1; $day <= 31; $day++) { - $retstring.=''; + $retstring .= ''; } - $retstring.=""; + $retstring .= ""; print $retstring; print ''.$langs->trans("Cash"); //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '.$langs->trans($val); + print ''.$langs->trans($val); //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '; print ''; + print ''; print $theoricalnbofinvoiceforterminal[$terminalid][$key]; print ''; + print ''; print price($theoricalamountforterminal[$terminalid][$key]).'
    '; print '
    '.$langs->trans("RealAmount").''; - print ''; + print ''; print ''; - print ''; + print ''; + print ''; print '
    '.$langs->trans($val).''; print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); @@ -578,12 +578,12 @@ if (empty($action) || $action=="view") dol_fiche_end(); print '
    '; - print ''; + print ''; if ($object->status == CashControl::STATUS_DRAFT) { - print ''; + print ''; - print ''; + print ''; } print '
    '; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 72bb79545e5..0c0e3d1a99c 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -89,7 +89,7 @@ elseif ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { @@ -118,14 +118,14 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('ContactsAddresses'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); $formcompany = new FormCompany($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); /* *************************************************************************** */ @@ -134,7 +134,7 @@ $userstatic=new User($db); /* */ /* *************************************************************************** */ -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { @@ -201,10 +201,10 @@ if ($id > 0 || ! empty($ref)) print '
    '; // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); if ($res) break; } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 36f768991f8..91e6ab46c5a 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -63,14 +63,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="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new Facture($db); if ($object->fetch($id)) { $object->fetch_thirdparty(); - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); } @@ -78,20 +78,20 @@ if ($object->fetch($id)) * Actions */ -require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* * View */ -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Documents'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { @@ -105,60 +105,60 @@ if ($id > 0 || ! empty($ref)) $totalpaye = $object->getSommePaiement(); // 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']; } // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
    '; + $morehtmlref = '
    '; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // 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->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; 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 .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); @@ -178,8 +178,8 @@ if ($id > 0 || ! empty($ref)) $modulepart = 'facture'; $permission = $user->rights->facture->creer; $permtoedit = $user->rights->facture->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'; } else { diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 6769b184e40..36a2496bdcf 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -28,15 +28,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -if (! empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('companies', 'bills')); $id = GETPOST("facid", "int"); -$ref=GETPOST("ref", 'alpha'); +$ref = GETPOST("ref", 'alpha'); /* @@ -45,7 +45,7 @@ $ref=GETPOST("ref", 'alpha'); $form = new Form($db); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -62,50 +62,50 @@ $totalpaye = $object->getSommePaiement(); // Invoice content -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = ''.$langs->trans("BackToList").''; -$morehtmlref='
    '; +$morehtmlref = '
    '; // Ref customer -$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty -$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); +$morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); // 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->facture->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; + $morehtmlref .= ' : '; 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 .= '
    '; -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 12e437e6110..3e8ea324fda 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -33,15 +33,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'compta', 'admin', 'other')); @@ -104,19 +104,19 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicereccard','globalcard')); +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('facture_rec'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php -$arrayfields=array( +$arrayfields = array( 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), @@ -137,10 +137,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -151,8 +151,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -160,7 +160,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) $action=''; + if (GETPOST('cancel', 'alpha')) $action = ''; // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -168,24 +168,24 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_payment_mode=''; - $search_payment_term=''; - $search_day=''; - $search_year=''; - $search_month=''; - $search_day_date_when=''; - $search_year_date_when=''; - $search_month_date_when=''; - $search_recurring=''; - $search_frequency=''; - $search_unit_frequency=''; - $search_status=''; - $search_array_options=array(); + $search_ref = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_payment_mode = ''; + $search_payment_term = ''; + $search_day = ''; + $search_year = ''; + $search_month = ''; + $search_day_date_when = ''; + $search_year_date_when = ''; + $search_month_date_when = ''; + $search_recurring = ''; + $search_frequency = ''; + $search_unit_frequency = ''; + $search_status = ''; + $search_array_options = array(); } // Mass actions @@ -247,22 +247,22 @@ if ($search_societe) $sql .= natural_search('s.nom', $search_societ if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); -if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); -if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); +if (!empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); +if (!empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); if ($search_recurring == '1') $sql .= ' AND f.frequency > 0'; if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1); if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); if ($search_status != '' && $search_status >= -1) { - if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; - if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; - if ($search_status == -1) $sql.= ' AND suspended = 1'; + if ($search_status == 0) $sql .= ' AND frequency = 0 AND suspended = 0'; + if ($search_status == 1) $sql .= ' AND frequency != 0 AND suspended = 0'; + if ($search_status == -1) $sql .= ' AND suspended = 1'; } -$sql.=dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); -$sql.=dolSqlDateFilter('f.date_last_gen', $search_day_date_when, $search_month_date_when, $search_year_date_when); +$sql .= dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.date_last_gen', $search_day_date_when, $search_month_date_when, $search_year_date_when); -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -276,43 +276,43 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($socid) $param.='&socid='.urlencode($socid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year=' .urlencode($search_year); - if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); - if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); - if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); - if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); - if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); - if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); - if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); - if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($option) $param.="&option=".urlencode($option); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($socid) $param .= '&socid='.urlencode($socid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_day_date_when) $param .= '&search_day_date_when='.urlencode($search_day_date_when); + if ($search_month_date_when) $param .= '&search_month_date_when='.urlencode($search_month_date_when); + if ($search_year_date_when) $param .= '&search_year_date_when='.urlencode($search_year_date_when); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); + if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type); + if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); + if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); + if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($option) $param .= "&option=".urlencode($option); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); + $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
    '; @@ -661,7 +661,7 @@ if ($resql) { print " "; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "
    '.$langs->trans("NoRecordFound").'
    '; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; print '
    '; @@ -312,7 +312,7 @@ if ($object->id > 0) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
    '; print '
    '; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -337,7 +337,7 @@ if ($object->id > 0) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; print '
    '; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -365,7 +365,7 @@ if ($object->id > 0) print ''; - if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; + if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
    '; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
    '; print '
    '; if ($action == 'editmode') @@ -383,7 +383,7 @@ if ($object->id > 0) print ''; print '
    '; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
    '; print '
    '; @@ -414,39 +414,39 @@ if ($object->id > 0) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '
    ' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    ' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountHT').''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
    '; - if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) { - print ''; + print ''; } print '
    '; print $langs->trans('RevenueStamp'); print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
    '; print '
    '; @@ -467,7 +467,7 @@ if ($object->id > 0) } // Total with tax - print '
    ' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
    '.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
    '; if ($obj->fk_prelevement_bons > 0) { - $withdrawreceipt=new BonPrelevement($db); - $withdrawreceipt->id=$obj->fk_prelevement_bons; - $withdrawreceipt->ref=$obj->ref; + $withdrawreceipt = new BonPrelevement($db); + $withdrawreceipt->id = $obj->fk_prelevement_bons; + $withdrawreceipt->ref = $obj->ref; print $withdrawreceipt->getNomUrl(1); } print "
    '.$langs->trans("None").'
    '; - $out.= $langs->trans($this->attributes[$object->table_element]['label'][$key]); - $out.= '
    '; + print '
    '; print ''; - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1); + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1); print ''; print "\n"; if (is_array($listofactions) && count($listofactions)) { - $cacheusers=array(); + $cacheusers = array(); $cursorevent = 0; - foreach($listofactions as $action) + foreach ($listofactions as $action) { if ($max && $cursorevent >= $max) break; - $ref=$action->getNomUrl(1, -1); - $label=$action->getNomUrl(0, 38); + $ref = $action->getNomUrl(1, -1); + $label = $action->getNomUrl(0, 38); print ''; // Ref print ''; // Onwer print ''; // Type print ''; // Ref - print ''; + print ''; // Label print ''; // Date start @@ -856,7 +856,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel */ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { - global $user,$conf,$extrafields,$hookmanager; + global $user, $conf, $extrafields, $hookmanager; global $contextpage; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -869,12 +869,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $page = GETPOST('page', 'int'); $search_status = GETPOST("search_status", 'int'); - if ($search_status=='') $search_status=1; // always display active customer first + if ($search_status == '') $search_status = 1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_address = GETPOST("search_address", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); - $search_roles = GETPOST("search_roles", 'array'); + $search_roles = GETPOST("search_roles", 'array'); $socialnetworks = getArrayOfSocialNetworks(); @@ -902,10 +902,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="t.lastname"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.lastname"; - if (! empty($conf->clicktodial->enabled)) + if (!empty($conf->clicktodial->enabled)) { $user->fetch_clicktodial(); // lecture des infos de clicktodial du user } @@ -935,59 +935,59 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) { - foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { - $arrayfields["ef.".$key]=array( + if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { + $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), - 'position'=>1000+$extrafields->attributes[$contactstatic->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); } } } // Initialize array of search criterias - $search=array(); - foreach($arrayfields as $key => $val) + $search = array(); + foreach ($arrayfields as $key => $val) { $queryName = 'search_'.substr($key, 2); - if (GETPOST($queryName, 'alpha')){ - $search[substr($key, 2)]=GETPOST($queryName, 'alpha'); + if (GETPOST($queryName, 'alpha')) { + $search[substr($key, 2)] = GETPOST($queryName, 'alpha'); } } - $search_array_options=$extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); + $search_array_options = $extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_status = ''; + $search_status = ''; $search_name = ''; $search_roles = array(); $search_address = ''; $search_poste = ''; $search = array(); - $search_array_options=array(); + $search_array_options = array(); - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } } $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $newcardbutton.= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $newcardbutton .= dolGetButtonTitle($addcontact, '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); print load_fiche_titre($title, $newcardbutton, ''); print ''; @@ -998,23 +998,23 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; print ''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - 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 print "\n".'
    '.$ref.''; - if (! empty($action->userownerid)) + if (!empty($action->userownerid)) { if (is_object($cacheusers[$action->userownerid])) { @@ -262,17 +262,17 @@ class FormActions print ''; - $imgpicto=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + $imgpicto = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); else { - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + if ($action->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($action->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $action->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } print $imgpicto; @@ -284,8 +284,8 @@ class FormActions print ''.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); if ($action->datef) { - $tmpa=dol_getdate($action->datep); - $tmpb=dol_getdate($action->datef); + $tmpa = dol_getdate($action->datep); + $tmpb = dol_getdate($action->datef); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); @@ -335,39 +335,39 @@ class FormActions public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) { // phpcs:enable - global $langs,$user,$form,$conf; + global $langs, $user, $form, $conf; - if (! is_object($form)) $form=new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $caction=new CActionComm($this->db); + $caction = new CActionComm($this->db); // Suggest a list with manual events or all auto events - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); - array_unshift($arraylist, ' '); // Add empty line at start + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); + array_unshift($arraylist, ' '); // Add empty line at start //asort($arraylist); - if ($selected == 'manual') $selected='AC_OTH'; - if ($selected == 'auto') $selected='AC_OTH_AUTO'; + if ($selected == 'manual') $selected = 'AC_OTH'; + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); - $out=''; + $out = ''; - if (! empty($multiselect)) + if (!empty($multiselect)) { if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); } if ($nooutput) return $out; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 76b9d07a2c4..759b7cc4c0d 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -46,17 +46,17 @@ class FormCompany extends Form public function typent_array($mode = 0, $filter = '') { // phpcs:enable - global $langs,$mysoc; + global $langs, $mysoc; $effs = array(); $sql = "SELECT id, code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; - $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; - if ($filter) $sql.=" ".$filter; - $sql.= " ORDER by position, id"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; + if ($filter) $sql .= " ".$filter; + $sql .= " ORDER by position, id"; dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -65,11 +65,11 @@ class FormCompany extends Form while ($i < $num) { $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; + if (!$mode) $key = $objp->id; + else $key = $objp->code; if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); else $effs[$key] = $objp->libelle; - if ($effs[$key]=='-') $effs[$key]=''; + if ($effs[$key] == '-') $effs[$key] = ''; $i++; } $this->db->free($resql); @@ -93,11 +93,11 @@ class FormCompany extends Form $sql = "SELECT id, code, libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; - $sql.= " WHERE active = 1"; - if ($filter) $sql.=" ".$filter; + $sql .= " WHERE active = 1"; + if ($filter) $sql .= " ".$filter; $sql .= " ORDER BY id ASC"; dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -106,10 +106,10 @@ class FormCompany extends Form while ($i < $num) { $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; + if (!$mode) $key = $objp->id; + else $key = $objp->code; - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; + $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; $i++; } $this->db->free($resql); @@ -139,9 +139,9 @@ class FormCompany extends Form dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; - $sql.= " WHERE active > 0"; - $sql.= " ORDER BY sortorder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); if ($resql) { @@ -164,7 +164,7 @@ class FormCompany extends Form print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; print ''; } @@ -203,88 +203,88 @@ class FormCompany extends Form public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); $langs->load("dict"); - $out=''; + $out = ''; // Serch departements/cantons/province active d'une region et pays actif $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + if ($country_codeid && !is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; $sql .= " ORDER BY c.code, d.code_departement"; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { - if (!empty($htmlname)) $out.= ''; + if ($country_codeid) $out .= ''; $num = $this->db->num_rows($result); $i = 0; dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); if ($num) { - $country=''; + $country = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); if ($obj->code == '0') // Le code peut etre une chaine { - $out.= ''; + $out .= ''; } else { - if (! $country || $country != $obj->country) + if (!$country || $country != $obj->country) { // Affiche la rupture si on est en mode liste multipays - if (! $country_codeid && $obj->country_code) + if (!$country_codeid && $obj->country_code) { - $out.= '\n"; - $country=$obj->country; + $out .= '\n"; + $country = $obj->country; } } - if ((! empty($selected) && $selected == $obj->rowid) - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) + if ((!empty($selected) && $selected == $obj->rowid) + || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) { - $out.= ''; + $out .= ''; } $i++; } } - if (! empty($htmlname)) $out.= ''; - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if (!empty($htmlname)) $out .= ''; + if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } else { @@ -292,9 +292,9 @@ class FormCompany extends Form } // Make select dynamic - if (! empty($htmlname)) + if (!empty($htmlname)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } @@ -316,16 +316,16 @@ class FormCompany extends Form public function select_region($selected = '', $htmlname = 'region_id') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $langs->load("dict"); $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; - $sql.= " ORDER BY c.code, c.label ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; + $sql .= " ORDER BY c.code, c.label ASC"; dol_syslog(get_class($this)."::select_region", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { print ''; - $out.= ''; + $out .= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ''; + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } else { @@ -460,10 +460,10 @@ class FormCompany extends Form public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') { // phpcs:enable - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $out=''; + $out = ''; // On recherche les formes juridiques actives des pays actifs $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; @@ -475,70 +475,70 @@ class FormCompany extends Form $sql .= " ORDER BY c.code"; dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $out.= '
    '; - $out.= ''; + if ($country_codeid) $out .= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. $num = $this->db->num_rows($resql); if ($num) { $i = 0; - $country=''; $arraydata=array(); + $country = ''; $arraydata = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj->code) // We exclude empty line, we will add it later { - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); - $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); + $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); + $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) + $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); } $i++; } - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); + $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) { - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); + $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); } - foreach($arraydata as $key => $val) + foreach ($arraydata as $key => $val) { - if (! $country || $country != $val['country']) + if (!$country || $country != $val['country']) { // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out.= '\n"; - $country=$val['country']; + $out .= '\n"; + $country = $val['country']; } } if ($selected > 0 && $selected == $val['code']) { - $out.= ''; + $out .= $val['label']; + $out .= ''; } } - $out.= ''; - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ''; + if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); - $out.= '
    '; + $out .= ''; } else { @@ -566,15 +566,15 @@ class FormCompany extends Form { global $conf, $langs; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { // Use Ajax search - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); - $socid=0; $name=''; + $socid = 0; $name = ''; if ($selected > 0) { - $tmpthirdparty=new Societe($this->db); + $tmpthirdparty = new Societe($this->db); $result = $tmpthirdparty->fetch($selected); if ($result > 0) { @@ -584,13 +584,13 @@ class FormCompany extends Form } - $events=array(); + $events = array(); // Add an entry 'method' to say 'yes, we must execute url with param action = method'; // Add an entry 'url' to say which url to execute // Add an entry htmlname to say which element we must change once url is called // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines // To refresh contacts list on thirdparty list change - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events { @@ -646,29 +646,29 @@ class FormCompany extends Form print "\n".''."\n"; print ''; - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); return $socid; } else { // Search to list thirdparties $sql = "SELECT s.rowid, s.nom as name FROM"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { - $sql.= " AND s.rowid IN (".join(',', $limitto).")"; + $sql .= " AND s.rowid IN (".join(',', $limitto).")"; } - $sql.= " ORDER BY s.nom ASC"; + $sql .= " ORDER BY s.nom ASC"; $resql = $this->db->query($sql); if ($resql) { - print '\n"; @@ -729,9 +729,9 @@ class FormCompany extends Form if (is_object($object) && method_exists($object, 'liste_type_contact')) { $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); - print ''; if ($showempty) print ''; - foreach($lesTypes as $key=>$value) + foreach ($lesTypes as $key=>$value) { print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } - $out .= ''; - } elseif ($typeinput=='list') { - $out .= ''; + $out .= ''; + } elseif ($typeinput == 'list') { + $out .= ''; if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } - $out .= ''; - $out .= ''; - } elseif ($typeinput=='admin') { + $out .= ''; + $out .= ''; + } elseif ($typeinput == 'admin') { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } } $out .= ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 2ad3a190cfc..a21f06dacfe 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -22,12 +22,12 @@ * \ingroup ticket * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire */ -require_once DOL_DOCUMENT_ROOT . "/core/class/html.form.class.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formmail.class.php"; -require_once DOL_DOCUMENT_ROOT . "/core/class/html.formprojet.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formprojet.class.php"; if (!class_exists('FormCompany')) { - include DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; + include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; } /** @@ -117,7 +117,7 @@ class FormTicket $this->withcreatereadonly = 1; $this->withemail = 0; $this->withref = 0; - $this->withextrafields = 0; // Show extrafields or not + $this->withextrafields = 0; // Show extrafields or not //$this->withtopicreadonly=0; } @@ -152,26 +152,26 @@ class FormTicket if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); - print '
    '; - print ''; - print ''; + print ''; + print ''; + print ''; foreach ($this->param as $key => $value) { - print ''; + print ''; } - print ''; + print ''; print ''; if ($this->withref) { // Ref $defaultref = $ticketstat->getDefaultRef(); - print ''; + print ''; } // TITLE if ($this->withemail) { - print ''; } @@ -184,7 +184,7 @@ class FormTicket $subelement = $regs[2]; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($this->db); $objectsrc->fetch(GETPOST('originid', 'int')); @@ -195,53 +195,53 @@ class FormTicket $objectsrc->fetch_thirdparty(); $newclassname = $classname; - print ''; + print ''; } // Type - print ''; // Severity - print ''; // Group - print ''; // Subject if ($this->withtitletopic) { - print ''; } else { if ($this->withthreadid > 0) { - $subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . ''; + $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withthreadid.' : '.$this->topic_title.''; } - print ''; + print ''; print ''; } } // MESSAGE $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : ''; - print ''; - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { $htmlname = 'socid'; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; foreach ($this->param as $key => $value) { - print ''; + print ''; } // Get message template - $model_id=0; + $model_id = 0; if (array_key_exists('models_id', $this->param)) { - $model_id=$this->param["models_id"]; - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); + $model_id = $this->param["models_id"]; + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); } $result = $formmail->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); - if ($result<0) { + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } - $modelmail_array=array(); + $modelmail_array = array(); foreach ($formmail->lines_model as $line) { - $modelmail_array[$line->id]=$line->label; + $modelmail_array[$line->id] = $line->label; } - print '
    ' . $langs->trans("Ref") . '
    '.$langs->trans("Ref").'
    '; - print ''; + print '
    '; + print ''; print '
    ' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
    '.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
    '; + print '
    '; $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); print '
    '; + print '
    '; $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); print '
    '; + print '
    '; $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); print '
    '; + print '
    '; // Réponse à un ticket : affichage du titre du thread en readonly if ($this->withtopicreadonly) { - print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title; + print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; print '
    '; + print '
    '; // If public form, display more information $toolbarname = 'dolibarr_notes'; if ($this->ispublic) { $toolbarname = 'dolibarr_details'; - print '
    ' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '
    '; + print '
    '.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')).'
    '; } - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_8, '90%'); $doleditor->Create(); @@ -249,7 +249,7 @@ class FormTicket // FK_USER_CREATE if ($this->withusercreate > 0 && $this->fk_user_create) { - print '
    ' . $langs->trans("CreatedBy") . ''; + print '
    '.$langs->trans("CreatedBy").''; $langs->load("users"); $fuser = new User($this->db); @@ -267,12 +267,12 @@ class FormTicket // altairis: force company and contact id for external user if (empty($user->socid)) { // Company - print '
    ' . $langs->trans("ThirdParty") . ''; + print '
    '.$langs->trans("ThirdParty").''; $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200'); print '
    '; + print '
    '; // External users can't send message email if ($user->rights->ticket->write && !$user->socid) @@ -891,11 +891,11 @@ class FormTicket print ''; // Zone to select its email template - if (count($modelmail_array)>0) { + if (count($modelmail_array) > 0) { print ''; } - print ''; + print ''; $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - print ''; // Destinataires - print ''; @@ -972,10 +972,10 @@ class FormTicket // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; - print ''; - $out .= ''; + $out .= ''; $out .= '\n"; @@ -1075,10 +1075,10 @@ class FormTicket print '
    '; $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : ''); print ' '; - print ''; + print ''; print '
    '; $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : ''); print ' '; - print ''; + print ''; print ''; print $form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); print '
    '; + print '
    '; //$toolbarname = 'dolibarr_details'; $toolbarname = 'dolibarr_notes'; - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70); $doleditor->Create(); print ''; @@ -1025,10 +1025,10 @@ class FormTicket // External users can't send message email if ($user->rights->ticket->write && !$user->socid) { $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - print '
    ' . $langs->trans("MailFile") . ''.$langs->trans("MailFile").''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out .= '' . "\n"; + $out .= ''."\n"; $out .= '' . "\n"; + $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { - $out .= '
    '; - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; + $out .= '
    '; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { - $out .= ' '; + $out .= ' '; } $out .= '
    '; } } else { - $out .= $langs->trans("NoAttachedFiles") . '
    '; + $out .= $langs->trans("NoAttachedFiles").'
    '; } if ($this->withfile == 2) { // Can add other files - $out .= ''; + $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "
    '; print '

    '; - print ''; + print ''; if ($this->withcancel) { print "     "; - print "trans("Cancel") . "\">"; + print "trans("Cancel")."\">"; } print "
    \n"; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 4ff061933e9..de00ea85e6f 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -94,29 +94,29 @@ class InfoBox { global $conf; - $boxes=array(); + $boxes = array(); - $confuserzone='MAIN_BOXES_'.$zone; + $confuserzone = 'MAIN_BOXES_'.$zone; if ($mode == 'activated') // activated { $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; - $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND b.entity IN (0,".$conf->entity.")"; - if ($zone >= 0) $sql.= " AND b.position = ".$zone; - if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; - else $sql.= " AND b.fk_user = 0"; - $sql.= " ORDER BY b.box_order"; + $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; + $sql .= " WHERE b.box_id = d.rowid"; + $sql .= " AND b.entity IN (0,".$conf->entity.")"; + if ($zone >= 0) $sql .= " AND b.position = ".$zone; + if (is_object($user)) $sql .= " AND b.fk_user IN (0,".$user->id.")"; + else $sql .= " AND b.fk_user = 0"; + $sql .= " ORDER BY b.box_order"; } else // available { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; + $sql .= " WHERE d.entity IN (0,".$conf->entity.")"; } - dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -126,7 +126,7 @@ class InfoBox { $obj = $db->fetch_object($resql); - if (! in_array($obj->box_id, $excludelist)) + if (!in_array($obj->box_id, $excludelist)) { if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { @@ -136,7 +136,7 @@ class InfoBox } else { - $boxname=preg_replace('/\.php$/i', '', $obj->file); + $boxname = preg_replace('/\.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/".$boxname.".php"; } @@ -148,48 +148,48 @@ class InfoBox dol_include_once($relsourcefile); if (class_exists($boxname)) { - $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. + $box = new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); // box properties - $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); - $box->id = (empty($obj->box_id) ? '' : $obj->box_id); - $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must stay '0' + $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); + $box->id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must stay '0' $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); - $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); - $box->sourcefile= $relsourcefile; + $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); + $box->sourcefile = $relsourcefile; $box->class = $boxname; - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database + if ($mode == 'activated' && !is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { - if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order; - elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order; + if ($box->box_order % 2 == 1) $box->box_order = 'A'.$box->box_order; + elseif ($box->box_order % 2 == 0) $box->box_order = 'B'.$box->box_order; } } // box_def properties - $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); - $box->note = (empty($obj->note) ? '' : $obj->note); + $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->note = (empty($obj->note) ? '' : $obj->note); // Filter on box->enabled (used for example by box_comptes) // Filter also on box->depends. Example: array("product|service") or array("contrat", "service") - $enabled=$box->enabled; + $enabled = $box->enabled; if (isset($box->depends) && count($box->depends) > 0) { - foreach($box->depends as $moduleelem) + foreach ($box->depends as $moduleelem) { - $arrayelem=explode('|', $moduleelem); - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) - foreach($arrayelem as $module) + $arrayelem = explode('|', $moduleelem); + $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) + foreach ($arrayelem as $module) { - $tmpmodule=preg_replace('/@[^@]+/', '', $module); - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; + $tmpmodule = preg_replace('/@[^@]+/', '', $module); + if (!empty($conf->$tmpmodule->enabled)) $tmpenabled = 1; //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
    '; } if (empty($tmpenabled)) // We found at least one module required that is disabled { - $enabled=0; + $enabled = 0; break; } } @@ -197,7 +197,7 @@ class InfoBox //print '=>'.$boxname.'-enabled='.$enabled.'
    '; //print 'xx module='.$module.' enabled='.$enabled; - if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box; + if ($enabled && ($includehidden || empty($box->hidden))) $boxes[] = $box; else unset($box); } else @@ -231,66 +231,66 @@ class InfoBox { global $conf; - $error=0; + $error = 0; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; dol_syslog(get_class()."::saveboxorder zone=".$zone." userid=".$userid); - if (! $userid || $userid == 0) return 0; + if (!$userid || $userid == 0) return 0; $user = new User($db); - $user->id=$userid; + $user->id = $userid; $db->begin(); // Save parameters to say user has a dedicated setup - $tab=array(); - $confuserzone='MAIN_BOXES_'.$zone; - $tab[$confuserzone]=1; + $tab = array(); + $confuserzone = 'MAIN_BOXES_'.$zone; + $tab[$confuserzone] = 1; if (dol_set_user_param($db, $conf, $user, $tab) < 0) { - $error=$db->lasterror(); + $error = $db->lasterror(); $db->rollback(); return -3; } // Delete all lines $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND fk_user = ".$userid; - $sql.= " AND position = ".$zone; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND fk_user = ".$userid; + $sql .= " AND position = ".$zone; dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); if ($result) { - $colonnes=explode('-', $boxorder); + $colonnes = explode('-', $boxorder); foreach ($colonnes as $collist) { - $part=explode(':', $collist); - $colonne=$part[0]; - $list=$part[1]; + $part = explode(':', $collist); + $colonne = $part[0]; + $list = $part[1]; dol_syslog(get_class()."::saveboxorder column=".$colonne.' list='.$list); - $i=0; - $listarray=explode(',', $list); + $i = 0; + $listarray = explode(',', $list); foreach ($listarray as $id) { if (is_numeric($id)) { //dol_syslog("aaaaa".count($listarray)); $i++; - $ii=sprintf('%02d', $i); + $ii = sprintf('%02d', $i); $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes"; - $sql.= "(box_id, position, box_order, fk_user, entity)"; - $sql.= " values ("; - $sql.= " ".$id.","; - $sql.= " ".$zone.","; - $sql.= " '".$colonne.$ii."',"; - $sql.= " ".$userid.","; - $sql.= " ".$conf->entity; - $sql.= ")"; + $sql .= "(box_id, position, box_order, fk_user, entity)"; + $sql .= " values ("; + $sql .= " ".$id.","; + $sql .= " ".$zone.","; + $sql .= " '".$colonne.$ii."',"; + $sql .= " ".$userid.","; + $sql .= " ".$conf->entity; + $sql .= ")"; dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); @@ -304,7 +304,7 @@ class InfoBox } if ($error) { - $error=$db->error(); + $error = $db->error(); $db->rollback(); return -2; } @@ -316,7 +316,7 @@ class InfoBox } else { - $error=$db->lasterror(); + $error = $db->lasterror(); $db->rollback(); dol_syslog(get_class()."::saveboxorder ".$error); return -1; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2af03656a64..3a9efd14c61 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -55,7 +55,7 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); - $nbContact = 0; // TODO + $nbContact = 0; // TODO $sql = "SELECT COUNT(p.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -104,7 +104,7 @@ function societe_prepare_head(Societe $object) $h++; } } - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Supplier"); @@ -112,16 +112,16 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) )) + if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id; $head[$h][1] = $langs->trans("Projects"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $sql.= " AND entity IN (".getEntity('project').")"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."projet as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND entity IN (".getEntity('project').")"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -150,10 +150,10 @@ function societe_prepare_head(Societe $object) $h++; } - if (! empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) + if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->client>0) + if (!empty($conf->accounting->enabled) && $object->client > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_customer.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringCustomer"); @@ -162,7 +162,7 @@ function societe_prepare_head(Societe $object) } // Tab to accountancy - if (! empty($conf->accounting->enabled) && $object->fournisseur>0) + if (!empty($conf->accounting->enabled) && $object->fournisseur > 0) { $head[$h][0] = DOL_URL_ROOT.'/accountancy/bookkeeping/thirdparty_lettering_supplier.php?socid='.$object->id; $head[$h][1] = $langs->trans("TabLetteringSupplier"); @@ -172,7 +172,7 @@ function societe_prepare_head(Societe $object) } // 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)) && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; @@ -184,31 +184,31 @@ function societe_prepare_head(Societe $object) // Bank accounts if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { - $nbBankAccount=0; - $foundonexternalonlinesystem=0; + $nbBankAccount = 0; + $foundonexternalonlinesystem = 0; $langs->load("banks"); //$title = $langs->trans("BankAccounts"); $title = $langs->trans("PaymentInformation"); - if (! empty($conf->stripe->enabled)) + if (!empty($conf->stripe->enabled)) { //$langs->load("stripe"); //$title = $langs->trans("BankAccountsAndGateways"); $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) $servicestatus = 1; include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; $societeaccount = new SocieteAccount($db); - $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... + $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... if ($stripecu) $foundonexternalonlinesystem++; } $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -216,7 +216,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbBankAccount=$obj->nb; + $nbBankAccount = $obj->nb; $i++; } } @@ -271,13 +271,13 @@ function societe_prepare_head(Societe $object) if ($user->socid == 0) { // Notifications - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n"; - $sql.= " WHERE fk_soc = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; + $sql .= " WHERE fk_soc = ".$object->id; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -285,7 +285,7 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } @@ -430,46 +430,46 @@ function societe_admin_prepare_head() */ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $entconv = 1, $searchlabel = '') { - global $db,$langs; + global $db, $langs; - $result=''; + $result = ''; // Check parameters if (empty($searchkey) && empty($searchlabel)) { - if ($withcode === 'all') return array('id'=>'','code'=>'','label'=>''); + if ($withcode === 'all') return array('id'=>'', 'code'=>'', 'label'=>''); else return ''; } - if (! is_object($dbtouse)) $dbtouse=$db; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($dbtouse)) $dbtouse = $db; + if (!is_object($outputlangs)) $outputlangs = $langs; $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; - if (is_numeric($searchkey)) $sql.= " WHERE rowid=".$searchkey; - elseif (! empty($searchkey)) $sql.= " WHERE code='".$db->escape($searchkey)."'"; - else $sql.= " WHERE label='".$db->escape($searchlabel)."'"; + if (is_numeric($searchkey)) $sql .= " WHERE rowid=".$searchkey; + elseif (!empty($searchkey)) $sql .= " WHERE code='".$db->escape($searchkey)."'"; + else $sql .= " WHERE label='".$db->escape($searchlabel)."'"; - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->label) && $obj->label!='-')?$obj->label:''); + $label = ((!empty($obj->label) && $obj->label != '-') ? $obj->label : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("Country".$obj->code)!="Country".$obj->code))?$outputlangs->trans("Country".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code))?$outputlangs->transnoentitiesnoconv("Country".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->trans("Country".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code)) ? $outputlangs->transnoentitiesnoconv("Country".$obj->code) : $label; } - if ($withcode == 1) $result=$label?"$obj->code - $label":"$obj->code"; - elseif ($withcode == 2) $result=$obj->code; - elseif ($withcode == 3) $result=$obj->rowid; - elseif ($withcode === 'all') $result=array('id'=>$obj->rowid,'code'=>$obj->code,'label'=>$label); - else $result=$label; + if ($withcode == 1) $result = $label ? "$obj->code - $label" : "$obj->code"; + elseif ($withcode == 2) $result = $obj->code; + elseif ($withcode == 3) $result = $obj->rowid; + elseif ($withcode === 'all') $result = array('id'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$label); + else $result = $label; } else { - $result='NotDefined'; + $result = 'NotDefined'; } $dbtouse->free($resql); return $result; @@ -495,58 +495,58 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', */ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1) { - global $db,$langs; + global $db, $langs; - if (! is_object($dbtouse)) $dbtouse=$db; + if (!is_object($dbtouse)) $dbtouse = $db; $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; $sql .= " ORDER BY c.code, d.code_departement"; dol_syslog("Company.lib::getState", LOG_DEBUG); - $resql=$dbtouse->query($sql); + $resql = $dbtouse->query($sql); if ($resql) { $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=((! empty($obj->name) && $obj->name!='-')?$obj->name:''); + $label = ((!empty($obj->name) && $obj->name != '-') ? $obj->name : ''); if (is_object($outputlangs)) { $outputlangs->load("dict"); - if ($entconv) $label=($obj->code && ($outputlangs->trans("State".$obj->code)!="State".$obj->code))?$outputlangs->trans("State".$obj->code):$label; - else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code)!="State".$obj->code))?$outputlangs->transnoentitiesnoconv("State".$obj->code):$label; + if ($entconv) $label = ($obj->code && ($outputlangs->trans("State".$obj->code) != "State".$obj->code)) ? $outputlangs->trans("State".$obj->code) : $label; + else $label = ($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code) != "State".$obj->code)) ? $outputlangs->transnoentitiesnoconv("State".$obj->code) : $label; } if ($withcode == 1) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode == 2) { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } else { - return $label = ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + return $label = ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); } } elseif ($withcode === 'all') { if ($withregion == 1) { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label,'region_code'=>$obj->region_code,'region'=>$obj->region_name); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label, 'region_code'=>$obj->region_code, 'region'=>$obj->region_name); } else { - return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label); + return array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$label); } } else { if ($withregion == 1) { - return $label = $obj->region_name . ' - ' . $label; + return $label = $obj->region_name.' - '.$label; } else { return $label; @@ -571,23 +571,23 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan */ function currency_name($code_iso, $withcode = '', $outputlangs = null) { - global $langs,$db; + global $langs, $db; - if (empty($outputlangs)) $outputlangs=$langs; + if (empty($outputlangs)) $outputlangs = $langs; $outputlangs->load("dict"); // If there is a translation, we can send immediatly the label - if ($outputlangs->trans("Currency".$code_iso)!="Currency".$code_iso) + if ($outputlangs->trans("Currency".$code_iso) != "Currency".$code_iso) { - return ($withcode?$code_iso.' - ':'').$outputlangs->trans("Currency".$code_iso); + return ($withcode ? $code_iso.' - ' : '').$outputlangs->trans("Currency".$code_iso); } // If no translation, we read table to get label by default $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; - $sql.= " WHERE code_iso='".$code_iso."'"; + $sql .= " WHERE code_iso='".$code_iso."'"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -595,8 +595,8 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->label!='-'?$obj->label:''); - if ($withcode) return ($label==$code_iso)?"$code_iso":"$code_iso - $label"; + $label = ($obj->label != '-' ? $obj->label : ''); + if ($withcode) return ($label == $code_iso) ? "$code_iso" : "$code_iso - $label"; else return $label; } else @@ -615,15 +615,15 @@ function currency_name($code_iso, $withcode = '', $outputlangs = null) */ function getFormeJuridiqueLabel($code) { - global $db,$langs; + global $db, $langs; - if (! $code) return ''; + if (!$code) return ''; $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; - $sql.= " WHERE code='$code'"; + $sql .= " WHERE code='$code'"; dol_syslog("Company.lib::getFormeJuridiqueLabel", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -631,7 +631,7 @@ function getFormeJuridiqueLabel($code) if ($num) { $obj = $db->fetch_object($resql); - $label=($obj->libelle!='-' ? $obj->libelle : ''); + $label = ($obj->libelle != '-' ? $obj->libelle : ''); return $label; } else @@ -654,43 +654,43 @@ function getCountriesInEEC() // List of all country codes that are in europe for european vat rules // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); - if (! empty($conf->global->MAIN_COUNTRIES_IN_EEC)) + if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) { // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); @@ -732,16 +732,16 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel { global $user; - $i = -1 ; + $i = -1; - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { $langs->load("projects"); - $newcardbutton=''; - if (! empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) + $newcardbutton = ''; + if (!empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink)) { - $newcardbutton.= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage)); } print "\n"; @@ -757,7 +757,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " ORDER BY p.dateo DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -779,7 +779,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel $projecttmp = new Project($db); - $i=0; + $i = 0; while ($i < $num) { @@ -794,7 +794,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print '
    '.img_object($langs->trans("ShowProject"), ($obj->public?'projectpub':'project'))." ".$obj->ref.''.img_object($langs->trans("ShowProject"), ($obj->public ? 'projectpub' : 'project'))." ".$obj->ref.''.$obj->title.'
    '."\n"; - $param="socid=".urlencode($object->id); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); - if ($search_name != '') $param.='&search_name='.urlencode($search_name); - if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); - if ($search_address != '') $param.='&search_address='.urlencode($search_address); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = "socid=".urlencode($object->id); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); + if ($search_name != '') $param .= '&search_name='.urlencode($search_name); + if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); + if ($search_address != '') $param .= '&search_address='.urlencode($search_address); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; @@ -1066,12 +1066,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; // ID - if (! empty($arrayfields['t.rowid']['checked'])) + if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions print ''; } print "\n
    '; @@ -1140,14 +1140,14 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); - $resultRole=$contactstatic->fetchRoles(); - if ($resultRole<0) { + $resultRole = $contactstatic->fetchRoles(); + if ($resultRole < 0) { setEventMessages(null, $contactstatic->errors, 'errors'); } if (is_array($contactstatic->array_options)) { - foreach($contactstatic->array_options as $key => $val) + foreach ($contactstatic->array_options as $key => $val) { $obj->$key = $val; } @@ -1156,7 +1156,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print '
    '; print $contactstatic->id; @@ -1164,7 +1164,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Photo - Name - if (! empty($arrayfields['t.name']['checked'])) + if (!empty($arrayfields['t.name']['checked'])) { print ''; print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 1); @@ -1173,7 +1173,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Job position - if (! empty($arrayfields['t.poste']['checked'])) + if (!empty($arrayfields['t.poste']['checked'])) { print ''; if ($obj->poste) print $obj->poste; @@ -1181,7 +1181,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Address - Phone - Email - if (! empty($arrayfields['t.address']['checked'])) + if (!empty($arrayfields['t.address']['checked'])) { print ''; print $contactstatic->getBannerAddress('contact', $object); @@ -1189,7 +1189,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Role - if (! empty($arrayfields['sc.role']['checked'])) + if (!empty($arrayfields['sc.role']['checked'])) { print ''; print $formcompany->showRoles("roles", $contactstatic, 'view'); @@ -1197,20 +1197,20 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } // Status - if (! empty($arrayfields['t.statut']['checked'])) + if (!empty($arrayfields['t.statut']['checked'])) { print ''.$contactstatic->getLibStatut(5).''; // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; print img_object($langs->trans("Event"), "action"); @@ -1233,8 +1233,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
    '.$langs->trans("None").'
    \n"; @@ -1260,7 +1260,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') */ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '') { - global $user,$conf; + global $user, $conf; $out = show_actions_done($conf, $langs, $db, $filterobj, $objcon, 1, $actioncode, 'todo'); @@ -1295,12 +1295,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -1311,7 +1311,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -1321,141 +1321,141 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin { $sql = "SELECT a.id, a.label as label,"; } - $sql.= " a.datep as dp,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent as percent, 'action' as type,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_contact,"; - $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " a.datep as dp,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $force_filter_contact = false; if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; } - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } } // Condition on actioncode - if (! empty($actioncode)) + if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; - else $sql.= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (! empty($conf->mailing->enabled) && ! empty($objcon->email) + if (!empty($conf->mailing->enabled) && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; - $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2.= " AND mc.statut = 1"; - $sql2.= " AND u.rowid = m.fk_user_valid"; - $sql2.= " AND mc.fk_mailing=m.rowid"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; } if (!empty($sql) && !empty($sql2)) { - $sql = $sql . " UNION " . $sql2; + $sql = $sql." UNION ".$sql2; } elseif (empty($sql) && !empty($sql2)) { $sql = $sql2; } //TODO Add limit in nb of results - $sql.= $db->order($sortfield_new, $sortorder); + $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) @@ -1464,19 +1464,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -1500,11 +1500,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -1740,8 +1740,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if ($result > 0) { $out .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $out .= '('.dol_print_phone($contact->phone_pro).')'; } $out .= '
    '; } @@ -1749,23 +1749,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= '
      '.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'], 3, 0, $histo[$key]['datestart']).'
    \n"; - $out.="\n"; + $out .= "
    \n"; + $out .= "\n"; } - $out.=''; + $out .= ''; if ($noprint) return $out; else print $out; @@ -1784,13 +1784,13 @@ function show_subsidiaries($conf, $langs, $db, $object) { global $user; - $i=-1; + $i = -1; $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.parent = ".$object->id; - $sql.= " AND s.entity IN (".getEntity('societe').")"; - $sql.= " ORDER BY s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$object->id; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); @@ -1808,7 +1808,7 @@ function show_subsidiaries($conf, $langs, $db, $object) print " "; print ""; - $i=0; + $i = 0; while ($i < $num) { diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index 4088b00c151..8128a449cfd 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -87,17 +87,17 @@ function dol_print_cron_urls() global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Cron launch print '
    '; print $langs->trans("URLToLaunchCronJobs").':
    '; - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; print img_picto('', 'globe').' '.$url."
    \n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'
    '; - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; print img_picto('', 'globe').' '.$url."
    \n"; print '
    '; print '
    '; @@ -107,22 +107,22 @@ function dol_print_cron_urls() print ''.$langs->trans("FileToLaunchCronJobs").':
    '; - $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; + $file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; print '
    \n"; print '
    '; // Add note if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) { - $linuxlike=1; - if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; - if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; + $linuxlike = 1; + if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; + if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; print $langs->trans("Note").': '; if ($linuxlike) { print $langs->trans("CronExplainHowToRunUnix"); print '
    '; - print '
    '; + print '
    '; } else { diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 568da82368f..66b39809b29 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -136,12 +136,12 @@ function showOnlinePaymentUrl($type, $ref) // Load translation files required by the page $langs->loadLangs(array('payment', 'paybox')); - $servicename=$langs->transnoentitiesnoconv('Online'); + $servicename = $langs->transnoentitiesnoconv('Online'); $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url = getOnlinePaymentUrl(0, $type, $ref); - $out.= ''; - $out.= ajax_autoselect("onlinepaymenturl", 0); + $out .= ''; + $out .= ajax_autoselect("onlinepaymenturl", 0); return $out; } @@ -160,12 +160,12 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag { global $conf, $dolibarr_main_url_root; - $ref=str_replace(' ', '', $ref); - $out=''; + $ref = str_replace(' ', '', $ref); + $out = ''; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $urltouse = DOL_MAIN_URL_ROOT; @@ -295,51 +295,51 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, global $conf; // Juridical status - $line1=""; + $line1 = ""; if ($fromcompany->forme_juridique_code) { - $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); + $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); } // Capital if ($fromcompany->capital) { - $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); + $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { - $field=$langs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; + $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; } // Prof Id 2 if ($fromcompany->idprof2) { - $field=$langs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; + $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; } // Second line of company infos - $line2=""; + $line2 = ""; // Prof Id 3 if ($fromcompany->idprof3) { - $field=$langs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; + $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; } // Prof Id 4 if ($fromcompany->idprof4) { - $field=$langs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; + $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { - $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; + $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } print '
    '; @@ -350,16 +350,16 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, print ''; print '
    '; - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); + elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); // Add other message if VAT exists if ($object->total_vat != 0 || $object->total_tva != 0) { - $parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; - if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); - elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); + $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; + if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); + elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); } } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index bdeb9181d3b..095a65c3584 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -45,7 +45,7 @@ function product_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (! empty($object->status)) + if (!empty($object->status)) { $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; $head[$h][1] = $langs->trans("SellingPrices"); @@ -53,10 +53,10 @@ function product_prepare_head($object) $h++; } - if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase + if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase { - if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) + if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) ) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; @@ -67,7 +67,7 @@ function product_prepare_head($object) } // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; $head[$h][1] = $langs->trans("Translation"); @@ -130,16 +130,16 @@ function product_prepare_head($object) // Tab to link resources if (!empty($conf->resource->enabled)) { - if ($object->isProduct() && ! empty($conf->global->RESOURCE_ON_PRODUCTS)) + if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=product&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; } - if ($object->isService() && ! empty($conf->global->RESOURCE_ON_SERVICES)) + if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES)) { - $head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=service&ref=' . $object->ref; + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref; $head[$h][1] = $langs->trans("Resources"); $head[$h][2] = 'resources'; $h++; @@ -188,10 +188,10 @@ function product_prepare_head($object) // Log $head[$h][0] = DOL_URL_ROOT.'/product/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++; @@ -210,7 +210,7 @@ function productlot_prepare_head($object) global $db, $langs, $conf, $user; // Load translation files required by the page - $langs->loadLangs(array("products","productbatch")); + $langs->loadLangs(array("products", "productbatch")); $h = 0; $head = array(); @@ -270,7 +270,7 @@ function product_admin_prepare_head() $head[$h][2] = 'general'; $h++; - if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { $head[$h] = array( 0 => DOL_URL_ROOT."/product/admin/price_rules.php", @@ -342,7 +342,7 @@ function product_lot_admin_prepare_head() */ function show_stats_for_company($product, $socid) { - global $conf,$langs,$user,$db; + global $conf, $langs, $user, $db; $nblines = 0; @@ -354,10 +354,10 @@ function show_stats_for_company($product, $socid) print ''; // Customer proposals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $nblines++; - $ret=$product->load_stats_propale($socid); + $ret = $product->load_stats_propale($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; @@ -372,10 +372,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier proposals - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $nblines++; - $ret=$product->load_stats_proposal_supplier($socid); + $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); print ''; @@ -390,10 +390,10 @@ function show_stats_for_company($product, $socid) print ''; } // Customer orders - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $nblines++; - $ret=$product->load_stats_commande($socid); + $ret = $product->load_stats_commande($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; @@ -408,10 +408,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier orders - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { $nblines++; - $ret=$product->load_stats_commande_fournisseur($socid); + $ret = $product->load_stats_commande_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); print ''; @@ -426,10 +426,10 @@ function show_stats_for_company($product, $socid) print ''; } // Customer invoices - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $nblines++; - $ret=$product->load_stats_facture($socid); + $ret = $product->load_stats_facture($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print ''; @@ -444,10 +444,10 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier invoices - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $nblines++; - $ret=$product->load_stats_facture_fournisseur($socid); + $ret = $product->load_stats_facture_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); print ''; @@ -463,10 +463,10 @@ function show_stats_for_company($product, $socid) } // Contracts - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $nblines++; - $ret=$product->load_stats_contrat($socid); + $ret = $product->load_stats_contrat($socid); if ($ret < 0) dol_print_error($db); $langs->load("contracts"); print ''; @@ -514,7 +514,7 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho { global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; - $measuringUnits= new CUnits($db); + $measuringUnits = new CUnits($db); if ($scale !== '') { @@ -534,10 +534,10 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho } $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter); - if ($result<0) { + if ($result < 0) { return -1; } else { - if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) { + if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) { if ($use_short_label) return $measuringUnits->records[key($measuringUnits->records)]->short_label; else return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); } else { @@ -555,8 +555,8 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho */ function measuring_units_squared($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m3 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m3 $measuring_units[-1] = -2; // dm-> dm2 $measuring_units[-2] = -4; // cm -> cm2 $measuring_units[-3] = -6; // mm -> mm2 @@ -575,8 +575,8 @@ function measuring_units_squared($unit) */ function measuring_units_cubed($unit) { - $measuring_units=array(); - $measuring_units[0] = 0; // m -> m2 + $measuring_units = array(); + $measuring_units[0] = 0; // m -> m2 $measuring_units[-1] = -3; // dm-> dm3 $measuring_units[-2] = -6; // cm -> cm3 $measuring_units[-3] = -9; // mm -> mm3 diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 21df0301d49..b7609ab82ae 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -259,13 +259,13 @@ function project_timesheet_prepare_head($mode, $fuser = null) $h = 0; - $param=''; - $param.=($mode?'&mode='.$mode:''); - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; + $param = ''; + $param .= ($mode ? '&mode='.$mode : ''); + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][2] = 'inputperweek'; $h++; @@ -273,7 +273,7 @@ function project_timesheet_prepare_head($mode, $fuser = null) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) { - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); $head[$h][1] = $langs->trans("InputPerDay"); $head[$h][2] = 'inputperday'; $h++; @@ -353,10 +353,10 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t global $user, $bc, $langs, $conf, $db; global $projectstatic, $taskstatic; - $lastprojectid=0; + $lastprojectid = 0; - $projectsArrayId=explode(',', $projectsListId); - if ($filterprogresscalc!=='') { + $projectsArrayId = explode(',', $projectsListId); + if ($filterprogresscalc !== '') { foreach ($lines as $key=>$line) { if (!empty($line->planned_workload) && !empty($line->duration)) { $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); @@ -365,27 +365,27 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } } - $lines=array_values($lines); + $lines = array_values($lines); } - $numlines=count($lines); + $numlines = count($lines); // We declare counter as global because we want to edit them into recursive call global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed; if ($level == 0) { - $total_projectlinesa_spent=0; - $total_projectlinesa_planned=0; - $total_projectlinesa_spent_if_planned=0; - $total_projectlinesa_declared_if_planned=0; - $total_projectlinesa_tobill=0; - $total_projectlinesa_billed=0; + $total_projectlinesa_spent = 0; + $total_projectlinesa_planned = 0; + $total_projectlinesa_spent_if_planned = 0; + $total_projectlinesa_declared_if_planned = 0; + $total_projectlinesa_tobill = 0; + $total_projectlinesa_billed = 0; } - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines // Process line // print "i:".$i."-".$lines[$i]->fk_project.'
    '; @@ -393,26 +393,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines { // Show task line. - $showline=1; - $showlineingray=0; + $showline = 1; + $showlineingray = 0; // If there is filters to use if (is_array($taskrole)) { // If task not legitimate to show, search if a legitimate task exists later in tree - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) { // So search if task has a subtask legitimate to show - $foundtaskforuserdeeper=0; + $foundtaskforuserdeeper = 0; searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'
    '; if ($foundtaskforuserdeeper > 0) { - $showlineingray=1; // We will show line but in gray + $showlineingray = 1; // We will show line but in gray } else { - $showline=0; // No reason to show line + $showline = 0; // No reason to show line } } } @@ -423,12 +423,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if (empty($user->rights->projet->all->lire)) { // User is not allowed on this project and project is not public, so we hide line - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) { // Note that having a user assigned to a task into a project user has no permission on, should not be possible // because assignement on task can be done only on contact of project. // If assignement was done and after, was removed from contact of project, then we can hide the line. - $showline=0; + $showline = 0; } } } @@ -439,26 +439,26 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; } print ''."\n"; - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->projectref; - $projectstatic->public=$lines[$i]->public; - $projectstatic->title=$lines[$i]->projectlabel; - $projectstatic->usage_bill_time=$lines[$i]->usage_bill_time; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->projectref; + $projectstatic->public = $lines[$i]->public; + $projectstatic->title = $lines[$i]->projectlabel; + $projectstatic->usage_bill_time = $lines[$i]->usage_bill_time; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->ref; - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); + $taskstatic->id = $lines[$i]->id; + $taskstatic->ref = $lines[$i]->ref; + $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : ''); $taskstatic->projectstatus = $lines[$i]->projectstatus; $taskstatic->progress = $lines[$i]->progress; $taskstatic->fk_statut = $lines[$i]->status; $taskstatic->datee = $lines[$i]->date_end; - $taskstatic->planned_workload= $lines[$i]->planned_workload; - $taskstatic->duration_effective= $lines[$i]->duration; + $taskstatic->planned_workload = $lines[$i]->planned_workload; + $taskstatic->duration_effective = $lines[$i]->duration; if ($showproject) @@ -466,14 +466,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Project ref print ""; //if ($showlineingray) print ''; - if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); else print $projectstatic->getNomUrl(1, 'nolink'); //if ($showlineingray) print ''; print ""; // Project status print ''; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); print ""; } @@ -494,12 +494,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ""; if ($showlineingray) print ''; //else print ''; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } print $lines[$i]->label; - for ($k = 0 ; $k < $level ; $k++) + for ($k = 0; $k < $level; $k++) { print '
    '; } @@ -518,15 +518,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print ''; - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + $plannedworkloadoutputformat = 'allhourmin'; + $timespentoutputformat = 'allhourmin'; + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; // Planned Workload (in working hours) 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 + $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 if ($lines[$i]->planned_workload != '') { print $fullhour; @@ -539,7 +539,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Time spent print ''; if ($showlineingray) print ''; - else print '
    '; + else print ''; if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; @@ -600,20 +600,20 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); - $num=count($tab); - if (!empty($num)){ - foreach ($tab as $contacttask){ + $num = count($tab); + if (!empty($num)) { + foreach ($tab as $contacttask) { //var_dump($contacttask); if ($source == 'internal') $c = new User($db); else $c = new Contact($db); $c->fetch($contacttask['id']); - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '
    '; + print $c->getNomUrl(1).' ('.$contacttask['libelle'].')'.'
    '; } } } @@ -628,7 +628,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print "\n"; - if (! $showlineingray) $inc++; + if (!$showlineingray) $inc++; if ($level >= 0) // Call sublevels { @@ -662,7 +662,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); print ''; print ''; - if ($projectidfortotallink > 0) print '
    '; + if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; print ''; @@ -680,13 +680,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t if ($totalCalculatedProgress > $totalAverageDeclaredProgress) { $progressBarClass = 'progress-bar-danger'; - $badgeClass.= 'badge-danger'; + $badgeClass .= 'badge-danger'; } elseif ($totalCalculatedProgress * $warningRatio >= $totalAverageDeclaredProgress) { // warning if close at 1% $progressBarClass = 'progress-bar-warning'; - $badgeClass.= 'badge-warning'; + $badgeClass .= 'badge-warning'; } else { $progressBarClass = 'progress-bar-success'; - $badgeClass.= 'badge-success'; + $badgeClass .= 'badge-success'; } } @@ -719,7 +719,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } // Contacts of task - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { print ''; } @@ -1169,11 +1169,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Ref print ''; print ''; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->getNomUrl(1, 'withproject', 'time'); // Label task print '
    '; - for ($k = 0 ; $k < $level ; $k++) print "   "; + for ($k = 0; $k < $level; $k++) print "   "; print $taskstatic->label; //print "
    "; //for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -1221,20 +1221,20 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr else print '--:--'; print "\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } // Form to add new time @@ -1392,7 +1392,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $obj = &$lines[$i]; // To display extrafields // If we want all or we have a role on task, we show it - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); @@ -1530,7 +1530,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ */ // Project - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); @@ -1538,7 +1538,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } // Thirdparty - if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) + if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { print ''; if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); @@ -1596,25 +1596,25 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Time spent by user print ''; - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "\n"; - $disabledproject=1;$disabledtask=1; + $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { - $disabledproject=0; - $disabledtask=0; + $disabledproject = 0; + $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { - $disabledtask=1; + $disabledtask = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); @@ -1686,9 +1686,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); - foreach($ret as $key => $val) + foreach ($ret as $key => $val) { - $totalforeachday[$key]+=$val; + $totalforeachday[$key] += $val; } //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); //var_dump($totalforeachday); @@ -1717,8 +1717,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { //print 'Search in line with parent id = '.$parent.'
    '; - $numlines=count($lines); - for ($i = 0 ; $i < $numlines ; $i++) + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { // Process line $lines[$i] if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) @@ -1811,40 +1811,40 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { $project_year_filter = date("Y"); } - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; } } // Get id of project we must show tasks - $arrayidofprojects=array(); + $arrayidofprojects = array(); $sql1 = "SELECT p.rowid as projectid"; - $sql1.= $sql; + $sql1 .= $sql; $resql = $db->query($sql1); if ($resql) { - $i=0; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) { $objp = $db->fetch_object($resql); - $arrayidofprojects[$objp->projectid]=$objp->projectid; + $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } } else dol_print_error($db); - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; - $sql2.= " p.dateo, p.datee,"; - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; - $sql2.= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; - $sql2.= " ORDER BY p.title, p.ref"; + $sql2 .= " p.dateo, p.datee,"; + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; + $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; + $sql2 .= " ORDER BY p.title, p.ref"; $resql = $db->query($sql2); if ($resql) @@ -1859,7 +1859,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); @@ -1867,14 +1867,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); print "\n"; - $total_plannedworkload=0; - $total_declaredprogressworkload=0; + $total_plannedworkload = 0; + $total_declaredprogressworkload = 0; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -1887,7 +1887,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { - $projectstatic->ref=$objp->ref; + $projectstatic->ref = $objp->ref; $projectstatic->statut = $objp->status; $projectstatic->title = $objp->title; $projectstatic->datee = $db->jdate($objp->datee); @@ -1897,18 +1897,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''; print $projectstatic->getNomUrl(1); - if (! in_array('projectlabel', $hiddenfields)) print '
    '.dol_trunc($objp->title, 24); + if (!in_array('projectlabel', $hiddenfields)) print '
    '.dol_trunc($objp->title, 24); print ''; print ''; if ($objp->fk_soc > 0) { - $thirdpartystatic->id=$objp->fk_soc; - $thirdpartystatic->ref=$objp->socname; - $thirdpartystatic->name=$objp->socname; + $thirdpartystatic->id = $objp->fk_soc; + $thirdpartystatic->ref = $objp->socname; + $thirdpartystatic->name = $objp->socname; print $thirdpartystatic->getNomUrl(1); } print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); @@ -1922,19 +1922,19 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks { print ''.$objp->nb.''; - $plannedworkload=$objp->planned_workload; - $total_plannedworkload+=$plannedworkload; - if (! in_array('plannedworkload', $hiddenfields)) + $plannedworkload = $objp->planned_workload; + $total_plannedworkload += $plannedworkload; + if (!in_array('plannedworkload', $hiddenfields)) { - print ''.($plannedworkload?convertSecondToTime($plannedworkload):'').''; + print ''.($plannedworkload ?convertSecondToTime($plannedworkload) : '').''; } - if (! in_array('declaredprogress', $hiddenfields)) + if (!in_array('declaredprogress', $hiddenfields)) { - $declaredprogressworkload=$objp->declared_progess_workload; - $total_declaredprogressworkload+=$declaredprogressworkload; + $declaredprogressworkload = $objp->declared_progess_workload; + $total_declaredprogressworkload += $declaredprogressworkload; print ''; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."
    "; - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload, 0).'%':''); + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); print ''; } } @@ -1952,7 +1952,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print ''.$langs->trans("Total").""; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).''; print ''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).''; @@ -1960,8 +1960,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks if (empty($conf->global->PROJECT_HIDE_TASKS)) { print ''.$total_task.''; - if (! in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').''; - if (! in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload, 0).'%':'').''; + if (!in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').''; + if (!in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').''; } print ''; print ''; diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index c9527c54840..837f505c132 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -29,14 +29,14 @@ function showOnlineSignatureUrl($type, $ref) global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("payment","paybox")); + $langs->loadLangs(array("payment", "paybox")); - $servicename='Online'; + $servicename = 'Online'; $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; $url = getOnlineSignatureUrl(0, $type, $ref); - $out.= ''; - $out.= ajax_autoselect("onlinesignatureurl", 0); + $out .= ''; + $out .= ajax_autoselect("onlinesignatureurl", 0); return $out; } @@ -53,29 +53,29 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') { global $conf, $db, $langs; - $ref=str_replace(' ', '', $ref); - $out=''; + $ref = str_replace(' ', '', $ref); + $out = ''; if ($type == 'proposal') { - $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'':''); - if ($mode == 1) $out.='proposal_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if ($mode == 1) $out.='&hashp=hash_of_file'; + $out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'proposal_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if ($mode == 1) $out .= '&hashp=hash_of_file'; else { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propaltmp=new Propal($db); + $propaltmp = new Propal($db); $res = $propaltmp->fetch(0, $ref); if ($res <= 0) return 'FailedToGetProposal'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $ecmfile->fetch(0, '', $propaltmp->last_main_doc); - $hashp=$ecmfile->share; + $hashp = $ecmfile->share; if (empty($hashp)) { $out = $langs->trans("FeatureOnlineSignDisabled"); @@ -83,13 +83,13 @@ function getOnlineSignatureUrl($mode, $type, $ref = '') } else { - $out.='&hashp='.$hashp; + $out .= '&hashp='.$hashp; } } } // For multicompany - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities return $out; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 609dbd9926d..fd2d56c946b 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -77,7 +77,7 @@ function ticket_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id; + $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'tabTicket'; $h++; @@ -110,25 +110,25 @@ function ticket_prepare_head($object) // History $ticketViewType = "messaging"; - if(empty($_SESSION['ticket-view-type'])){ + if (empty($_SESSION['ticket-view-type'])) { $_SESSION['ticket-view-type'] = $ticketViewType; } - else{ + else { $ticketViewType = $_SESSION['ticket-view-type']; } - if($ticketViewType == "messaging"){ - $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id=' . $object->track_id; + if ($ticketViewType == "messaging") { + $head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id; } - else{ + else { // $ticketViewType == "list" - $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_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] = 'tabTicketLogs'; $h++; @@ -158,22 +158,22 @@ function showDirectPublicLink($object) $url = dol_buildpath('/public/ticket/view.php', 3).'?track_id='.$object->track_id.'&email='.$email; } - $out=''; + $out = ''; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - $out.= ''.$langs->trans("PublicInterfaceNotEnabled").''; + $out .= ''.$langs->trans("PublicInterfaceNotEnabled").''; } else { - $out.= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':
    '; + $out .= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':
    '; if ($url) { - $out.= ''; - $out.= ajax_autoselect("directpubliclink", 0); + $out .= ''; + $out .= ajax_autoselect("directpubliclink", 0); } else { - $out.= ''.$langs->trans("TicketNotCreatedFromPublicInterface").''; + $out .= ''.$langs->trans("TicketNotCreatedFromPublicInterface").''; } } @@ -272,12 +272,12 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_include_once('/comm/action/class/actioncomm.class.php'); // Check parameters - if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('', 'BadParameter'); + if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter'); - $out=''; - $histo=array(); - $numaction = 0 ; - $now=dol_now('tzuser'); + $out = ''; + $histo = array(); + $numaction = 0; + $now = dol_now('tzuser'); // Open DSI -- Fix order by -- Begin $sortfield_list = explode(',', $sortfield); @@ -288,7 +288,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } $sortfield_new = implode(',', $sortfield_new_list); - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm if (is_object($objcon) && $objcon->id > 0) { @@ -298,142 +298,142 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no { $sql = "SELECT a.id, a.label as label,"; } - $sql.= " a.datep as dp,"; - $sql.= " a.note as message,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent as percent, 'action' as type,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.fk_contact,"; - $sql.= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + $sql .= " a.datep as dp,"; + $sql .= " a.note as message,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.fk_contact,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; $force_filter_contact = false; if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; - $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id; } - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') { - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; - $sql.= " ON er.resource_type = 'dolresource'"; - $sql.= " AND er.element_id = a.id"; - $sql.= " AND er.resource_id = ".$filterobj->id; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " ON er.resource_type = 'dolresource'"; + $sql .= " AND er.element_id = a.id"; + $sql .= " AND er.resource_id = ".$filterobj->id; } - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; if ($force_filter_contact === false) { - if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; - elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id; + elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; - if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'"; + if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id; } } // Condition on actioncode - if (! empty($actioncode)) + if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; - else $sql.= " AND c.code = '".$db->escape($actioncode)."'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else $sql .= " AND c.code = '".$db->escape($actioncode)."'"; } } - if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); + if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']); } // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (! empty($conf->mailing->enabled) && ! empty($objcon->email) + if (!empty($conf->mailing->enabled) && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) { $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id"; - $sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; - $sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action - if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2.= ", '' as lastname, '' as firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2.= ", '' as ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2.= ", '' as ref"; - $sql2.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; - $sql2.= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. - $sql2.= " AND mc.statut = 1"; - $sql2.= " AND u.rowid = m.fk_user_valid"; - $sql2.= " AND mc.fk_mailing=m.rowid"; + $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; + $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action + if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname"; + elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email. + $sql2 .= " AND mc.statut = 1"; + $sql2 .= " AND u.rowid = m.fk_user_valid"; + $sql2 .= " AND mc.fk_mailing=m.rowid"; } if (!empty($sql) && !empty($sql2)) { - $sql = $sql . " UNION " . $sql2; + $sql = $sql." UNION ".$sql2; } elseif (empty($sql) && !empty($sql2)) { $sql = $sql2; } //TODO Add limit in nb of results - $sql.= $db->order($sortfield_new, $sortorder); + $sql .= $db->order($sortfield_new, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); while ($i < $num) @@ -442,19 +442,19 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no if ($obj->type == 'action') { $contactaction = new ActionComm($db); - $contactaction->id=$obj->id; + $contactaction->id = $obj->id; $result = $contactaction->fetchResources(); - if ($result<0) { + if ($result < 0) { dol_print_error($db); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone=''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo'; - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>$tododone, 'id'=>$obj->id, @@ -479,11 +479,11 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no // Type of event 'acode'=>$obj->acode, 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated + 'libelle'=>$obj->alabel, // deprecated 'apicto'=>$obj->apicto ); } else { - $histo[$numaction]=array( + $histo[$numaction] = array( 'type'=>$obj->type, 'tododone'=>'done', 'id'=>$obj->id, @@ -511,85 +511,85 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_print_error($db); } - if (! empty($conf->agenda->enabled) || (! empty($conf->mailing->enabled) && ! empty($objcon->email))) + if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) { - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $formactions=new FormActions($db); + $formactions = new FormActions($db); - $actionstatic=new ActionComm($db); - $userstatic=new User($db); + $actionstatic = new ActionComm($db); + $userstatic = new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); - $out.='
    '; - $out.='
    '; + $out .= '
    '; + $out .= ''; if ($objcon && get_class($objcon) == 'Contact' && (is_null($filterobj) || get_class($filterobj) == 'Societe')) { - $out.=''; + $out .= ''; } else { - $out.=''; + $out .= ''; } - if ($filterobj && get_class($filterobj) == 'Societe') $out.=''; + if ($filterobj && get_class($filterobj) == 'Societe') $out .= ''; - $out.="\n"; + $out .= "\n"; - $out.='
    '; - $out.=''; + $out .= '
    '; + $out .= '
    '; - $out.=''; + $out .= ''; //$out.=''; - $out.=''; + $out .= ''; if ($donetodo) { - $out.=''; + $out .= ''; } - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $out.='
    '; $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n"; //$out.=''.$langs->trans("Search").' : '.$langs->trans("Search").' : '.$langs->trans("Type").' '; - $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); - $out.=''; - $out.=$langs->trans("Label").' '; - $out.=''; - $out.=''.$langs->trans("Type").' '; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1); + $out .= ''; + $out .= $langs->trans("Label").' '; + $out .= ''; + $out .= ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - $out.=$searchpicto; - $out.='
    '; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
    '; + $out .= ''; - $out.=''; - $out.='
    '; + $out .= ''; + $out .= '
    '; - $out.="\n"; + $out .= "\n"; - $out.='
      '; + $out .= '
        '; if ($donetodo) { - $tmp=''; - if (get_class($filterobj) == 'Societe') $tmp.=''; - $tmp.=($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); - $tmp.=($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); - $tmp.=($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); + $tmp = ''; + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); + $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); + $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); //$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); - if (get_class($filterobj) == 'Societe') $tmp.=''; - $out.=getTitleFieldOfList($tmp); + if (get_class($filterobj) == 'Societe') $tmp .= ''; + $out .= getTitleFieldOfList($tmp); } @@ -601,69 +601,69 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no foreach ($histo as $key=>$value) { - $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo + $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo - $actionstatic->type_picto=$histo[$key]['apicto']; - $actionstatic->type_code=$histo[$key]['acode']; + $actionstatic->type_picto = $histo[$key]['apicto']; + $actionstatic->type_code = $histo[$key]['acode']; $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$histo[$key]['id']; - $tmpa=dol_getdate($histo[$key]['datestart'], false); - if($actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']){ + $tmpa = dol_getdate($histo[$key]['datestart'], false); + if ($actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']) { $actualCycleDate = $tmpa['year'].'-'.$tmpa['yday']; - $out.=''; - $out.='
      • '; - $out.=''; - $out.= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs); - $out.=''; - $out.='
      • '; - $out.=''; + $out .= ''; + $out .= '
      • '; + $out .= ''; + $out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs); + $out .= ''; + $out .= '
      • '; + $out .= ''; } - $out.=''."\n"; - $out.='
      • '; + $out .= ''."\n"; + $out .= '
      • '; - $out.=''."\n"; + $out .= ''."\n"; $iconClass = 'fa fa-comments'; $img_picto = ''; $colorClass = ''; $pictoTitle = ''; - if ($histo[$key]['percent']==-1) { + if ($histo[$key]['percent'] == -1) { $colorClass = 'timeline-icon-not-applicble'; $pictoTitle = $langs->trans('StatusNotApplicable'); } - elseif ($histo[$key]['percent']==0) { + elseif ($histo[$key]['percent'] == 0) { $colorClass = 'timeline-icon-todo'; - $pictoTitle = $langs->trans('StatusActionToDo') . ' (0%)'; + $pictoTitle = $langs->trans('StatusActionToDo').' (0%)'; } - elseif ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100){ + elseif ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100) { $colorClass = 'timeline-icon-in-progress'; $pictoTitle = $langs->trans('StatusActionInProcess').' ('.$histo[$key]['percent'].'%)'; } - elseif ($histo[$key]['percent'] >= 100){ + elseif ($histo[$key]['percent'] >= 100) { $colorClass = 'timeline-icon-done'; - $pictoTitle = $langs->trans('StatusActionDone').' (100%)'; + $pictoTitle = $langs->trans('StatusActionDone').' (100%)'; } - if($actionstatic->code == 'AC_TICKET_CREATE'){ + if ($actionstatic->code == 'AC_TICKET_CREATE') { $iconClass = 'fa fa-ticket'; } - elseif($actionstatic->code == 'AC_TICKET_MODIFY'){ + elseif ($actionstatic->code == 'AC_TICKET_MODIFY') { $iconClass = 'fa fa-pencil'; } - elseif($actionstatic->code == 'TICKET_MSG'){ + elseif ($actionstatic->code == 'TICKET_MSG') { $iconClass = 'fa fa-comments'; } - elseif($actionstatic->code == 'TICKET_MSG_PRIVATE'){ + elseif ($actionstatic->code == 'TICKET_MSG_PRIVATE') { $iconClass = 'fa fa-mask'; } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actionstatic->type_picto) $img_picto = img_picto('', $actionstatic->type_picto); + if ($actionstatic->type_picto) $img_picto = img_picto('', $actionstatic->type_picto); else { if ($actionstatic->type_code == 'AC_RDV') $iconClass = 'fa fa-handshake'; elseif ($actionstatic->type_code == 'AC_TEL') $iconClass = 'fa fa-phone'; @@ -671,24 +671,24 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no elseif ($actionstatic->type_code == 'AC_EMAIL') $iconClass = 'fa fa-envelope'; elseif ($actionstatic->type_code == 'AC_INT') $iconClass = 'fa fa-shipping-fast'; elseif ($actionstatic->type_code == 'AC_OTH_AUTO') $iconClass = 'fa fa-robot'; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) $iconClass = 'fa fa-robot'; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $iconClass = 'fa fa-robot'; } } - $out.=''.$img_picto.''."\n"; + $out .= ''.$img_picto.''."\n"; - $out.='
        '."\n"; + $out .= '
        '."\n"; - $out.=''; + $out .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $out.=$histo[$key]['id']; - $out.=' '; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $out .= $histo[$key]['id']; + $out .= ' '; } else { - $out.=$actionstatic->getNomUrl(1, -1).' '; + $out .= $actionstatic->getNomUrl(1, -1).' '; } //if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) @@ -765,16 +765,16 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= ''; - $out.=''; + $out .= ''; - if (! empty($histo[$key]['message']) + if (!empty($histo[$key]['message']) && $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_MODIFY' ) { - $out.='
        '; - $out.=$histo[$key]['message']; - $out.='
        '; + $out .= '
        '; + $out .= $histo[$key]['message']; + $out .= '
        '; } @@ -792,11 +792,11 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no dol_print_error($db, $contact->error); if ($result > 0) { - $contactList.= !empty($contactList)?', ':''; + $contactList .= !empty($contactList) ? ', ' : ''; $contactList .= $contact->getNomUrl(1); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { - if (! empty($contact->phone_pro)) - $contactList .= '(' . dol_print_phone($contact->phone_pro) . ')'; + if (!empty($contact->phone_pro)) + $contactList .= '('.dol_print_phone($contact->phone_pro).')'; } } } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 08ac267445d..d6c43edd5c3 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -25,7 +25,7 @@ * \brief File to load import files with CSV format */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; /** @@ -43,7 +43,7 @@ class ImportCsv extends ModeleImports /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -60,7 +60,7 @@ class ImportCsv extends ModeleImports */ public $label; - public $extension; // Extension of files imported by driver + public $extension; // Extension of files imported by driver /** * Dolibarr version of driver @@ -68,19 +68,19 @@ class ImportCsv extends ModeleImports */ public $version = 'dolibarr'; - public $label_lib; // Label of external lib used by driver + public $label_lib; // Label of external lib used by driver - public $version_lib; // Version of external lib used by driver + public $version_lib; // Version of external lib used by driver public $separator; - public $file; // Path of file + public $file; // Path of file - public $handle; // Handle fichier + public $handle; // Handle fichier - public $cacheconvert=array(); // Array to cache list of value found after a convertion + public $cacheconvert = array(); // Array to cache list of value found after a convertion - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables + public $cachefieldtable = array(); // Array to cache list of value found into fields@tables public $nbinsert = 0; // # of insert done during the import @@ -98,23 +98,23 @@ class ImportCsv extends ModeleImports global $conf, $langs; $this->db = $db; - $this->separator=(GETPOST('separator')?GETPOST('separator'):(empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)?',':$conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); - $this->enclosure='"'; - $this->escape='"'; + $this->separator = (GETPOST('separator') ?GETPOST('separator') : (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); + $this->enclosure = '"'; + $this->escape = '"'; - $this->id='csv'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Csv'; // Label of driver - $this->desc=$langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); - $this->extension='csv'; // Extension for generated file by this driver - $this->picto='mime/other'; // Picto - $this->version='1.34'; // Driver version + $this->id = 'csv'; // Same value then xxx in file name export_xxx.modules.php + $this->label = 'Csv'; // Label of driver + $this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape); + $this->extension = 'csv'; // Extension for generated file by this driver + $this->picto = 'mime/other'; // Picto + $this->version = '1.34'; // Driver version // If driver use an external library, put its name here - $this->label_lib='Dolibarr'; - $this->version_lib=DOL_VERSION; + $this->label_lib = 'Dolibarr'; + $this->version_lib = DOL_VERSION; - $this->datatoimport=$datatoimport; - if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject=new Societe($this->db); + $this->datatoimport = $datatoimport; + if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } @@ -142,7 +142,7 @@ class ImportCsv extends ModeleImports public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable - $s=join($this->separator, array_map('cleansep', $headerlinefields)); + $s = join($this->separator, array_map('cleansep', $headerlinefields)); return $s."\n"; } @@ -157,7 +157,7 @@ class ImportCsv extends ModeleImports public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable - $s=join($this->separator, array_map('cleansep', $contentlinevalues)); + $s = join($this->separator, array_map('cleansep', $contentlinevalues)); return $s."\n"; } @@ -187,22 +187,22 @@ class ImportCsv extends ModeleImports { // phpcs:enable global $langs; - $ret=1; + $ret = 1; dol_syslog(get_class($this)."::open_file file=".$file); - ini_set('auto_detect_line_endings', 1); // For MAC compatibility + ini_set('auto_detect_line_endings', 1); // For MAC compatibility $this->handle = fopen(dol_osencode($file), "r"); - if (! $this->handle) + if (!$this->handle) { $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToOpenFile", $file); - $ret=-1; + $this->error = $langs->trans("ErrorFailToOpenFile", $file); + $ret = -1; } else { - $this->file=$file; + $this->file = $file; } return $ret; @@ -247,47 +247,47 @@ class ImportCsv extends ModeleImports // phpcs:enable global $conf; - $arrayres=fgetcsv($this->handle, 100000, $this->separator, $this->enclosure, $this->escape); + $arrayres = fgetcsv($this->handle, 100000, $this->separator, $this->enclosure, $this->escape); // End of file if ($arrayres === false) return false; //var_dump($this->handle); //var_dump($arrayres);exit; - $newarrayres=array(); + $newarrayres = array(); if ($arrayres && is_array($arrayres)) { - foreach($arrayres as $key => $val) + foreach ($arrayres as $key => $val) { - if (! empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) // Forced charset + if (!empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) // Forced charset { if (strtolower($conf->global->IMPORT_CSV_FORCE_CHARSET) == 'utf8') { - $newarrayres[$key]['val']=$val; - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = $val; + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } else { - $newarrayres[$key]['val']=utf8_encode($val); - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = utf8_encode($val); + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } } else // Autodetect format (UTF8 or ISO) { if (utf8_check($val)) { - $newarrayres[$key]['val']=$val; - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = $val; + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } else { - $newarrayres[$key]['val']=utf8_encode($val); - $newarrayres[$key]['type']=(dol_strlen($val)?1:-1); // If empty we considere it's null + $newarrayres[$key]['val'] = utf8_encode($val); + $newarrayres[$key]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we considere it's null } } } - $this->col=count($newarrayres); + $this->col = count($newarrayres); } return $newarrayres; @@ -322,21 +322,21 @@ class ImportCsv extends ModeleImports public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable - global $langs,$conf,$user; - global $thirdparty_static; // Specific to thirdparty import - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables + global $langs, $conf, $user; + global $thirdparty_static; // Specific to thirdparty import + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables - $error=0; - $warning=0; - $this->errors=array(); - $this->warnings=array(); + $error = 0; + $warning = 0; + $this->errors = array(); + $this->warnings = array(); //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); //var_dump($arrayrecord); - $array_match_database_to_file=array_flip($array_match_file_to_database); - $sort_array_match_file_to_database=$array_match_file_to_database; + $array_match_database_to_file = array_flip($array_match_file_to_database); + $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); @@ -344,8 +344,8 @@ class ImportCsv extends ModeleImports if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) { //print 'W'; - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); - $this->warnings[$warning]['type']='EMPTY'; + $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); + $this->warnings[$warning]['type'] = 'EMPTY'; $warning++; } else @@ -354,25 +354,25 @@ class ImportCsv extends ModeleImports $updatedone = false; $insertdone = false; // For each table to insert, me make a separate insert - foreach($objimport->array_import_tables[0] as $alias => $tablename) + foreach ($objimport->array_import_tables[0] as $alias => $tablename) { // Build sql request - $sql=''; - $listfields=array(); - $listvalues=array(); - $i=0; - $errorforthistable=0; + $sql = ''; + $listfields = array(); + $listvalues = array(); + $i = 0; + $errorforthistable = 0; // Define $tablewithentity_cache[$tablename] if not already defined - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" + if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" { dol_syslog("Check if table ".$tablename." has an entity field"); - $resql=$this->db->DDLDescTable($tablename, 'entity'); + $resql = $this->db->DDLDescTable($tablename, 'entity'); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field + $obj = $this->db->fetch_object($resql); + if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field + else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field } else dol_print_error($this->db); } @@ -388,26 +388,26 @@ class ImportCsv extends ModeleImports } // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) - foreach($sort_array_match_file_to_database as $key => $val) + foreach ($sort_array_match_file_to_database as $key => $val) { - $fieldalias=preg_replace('/\..*$/i', '', $val); - $fieldname=preg_replace('/^.*\./i', '', $val); + $fieldalias = preg_replace('/\..*$/i', '', $val); + $fieldname = preg_replace('/^.*\./i', '', $val); - if ($alias != $fieldalias) continue; // Not a field of current table + if ($alias != $fieldalias) continue; // Not a field of current table if ($key <= $maxfields) { // Set $newval with value to insert and set $listvalues with sql request part for insert - $newval=''; - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value + $newval = ''; + if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval=='')) + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue', $key); - $this->errors[$error]['type']='NOTNULL'; + $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); + $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; } @@ -415,28 +415,28 @@ class ImportCsv extends ModeleImports else { // We convert field if required - if (! empty($objimport->array_import_convertvalue[0][$val])) + if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; - if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' + if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' ) { // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. - $isidorref='id'; - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i', $newval)) $isidorref='ref'; - $newval=preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref + $isidorref = 'id'; + if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
        \n"; if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; } else { @@ -446,7 +446,7 @@ class ImportCsv extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') @@ -550,11 +550,11 @@ class ImportCsv extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); - $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; if ($classinstance->id > 0) // we found record { @@ -562,91 +562,91 @@ class ImportCsv extends ModeleImports } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); - $newval=$this->thirpartyobject->code_client; + $newval = $this->thirpartyobject->code_client; //print 'code_client='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval=$this->thirpartyobject->get_codefournisseur(0, 1); - $newval=$this->thirpartyobject->code_fournisseur; + $newval = $this->thirpartyobject->get_codefournisseur(0, 1); + $newval = $this->thirpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); - $newval=$this->thirpartyobject->code_compta; + $newval = $this->thirpartyobject->code_compta; //print 'code_compta='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); - $newval=$this->thirpartyobject->code_compta_fournisseur; - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + $newval = $this->thirpartyobject->code_compta_fournisseur; + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" //print 'code_compta_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { - $defaultref=''; + $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(null, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; - $newval=$defaultref; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + $newval = $defaultref; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; $resultload = dol_include_once($file); if (empty($resultload)) { dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); - if ($res<0) { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if ($res < 0) { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } @@ -655,36 +655,36 @@ class ImportCsv extends ModeleImports } // Test regexp - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { - $field=$reg[1]; - $table=$reg[2]; - $filter=!empty($reg[3])?substr($reg[3], 1):''; + $field = $reg[1]; + $table = $reg[2]; + $filter = !empty($reg[3]) ?substr($reg[3], 1) : ''; $cachekey = $field.'@'.$table; - if(! empty($filter)) $cachekey.= ':'.$filter; + if (!empty($filter)) $cachekey .= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache + if (!is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { - $sql="SELECT ".$field." as aliasfield FROM ".$table; - if(! empty($filter)) + $sql = "SELECT ".$field." as aliasfield FROM ".$table; + if (!empty($filter)) { - $sql.= ' WHERE ' . $filter; + $sql .= ' WHERE '.$filter; } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; + $obj = $this->db->fetch_object($resql); + if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield; $i++; } } @@ -695,21 +695,21 @@ class ImportCsv extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) + if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; - if(! empty($filter)) $tableforerror.= ':'.$filter; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($filter)) $tableforerror .= ':'.$filter; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } // If test is just a static regex - elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
        "; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); - $this->errors[$error]['type']='REGEX'; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); + $this->errors[$error]['type'] = 'REGEX'; $errorforthistable++; $error++; } @@ -723,9 +723,9 @@ class ImportCsv extends ModeleImports $listfields[] = $fieldname; // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) { - $listvalues[] = ($newval=='0'?$newval:"null"); - } elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) { + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) { + $listvalues[] = ($newval == '0' ? $newval : "null"); + } elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) { $listvalues[] = "''"; } else { $listvalues[] = "'".$this->db->escape($newval)."'"; @@ -738,9 +738,9 @@ class ImportCsv extends ModeleImports if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach($objimport->array_import_fieldshidden[0] as $key => $val) + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table + if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); @@ -748,8 +748,8 @@ class ImportCsv extends ModeleImports } elseif (preg_match('/^lastrowid-/', $val)) { - $tmp=explode('-', $val); - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; + $tmp = explode('-', $val); + $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; @@ -757,14 +757,14 @@ class ImportCsv extends ModeleImports } elseif (preg_match('/^const-/', $val)) { - $tmp=explode('-', $val, 2); + $tmp = explode('-', $val, 2); $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = "'".$tmp[1]."'"; } else { - $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; - $this->errors[$error]['type']='Import profile setup'; + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type'] = 'Import profile setup'; $error++; } } @@ -773,7 +773,7 @@ class ImportCsv extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined // so we can try to make the insert or update now. - if (! $errorforthistable) + if (!$errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
        "; if (!empty($listfields)) @@ -792,21 +792,21 @@ class ImportCsv extends ModeleImports $filters = array(); foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; - $key=preg_replace('/^.*\./i', '', $key); + $key = preg_replace('/^.*\./i', '', $key); $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; } - $sqlSelect.= ' WHERE '.implode(' AND ', $where); + $sqlSelect .= ' WHERE '.implode(' AND ', $where); - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; - } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); - $this->errors[$error]['type']='SQL'; + } elseif ($resql->num_rows > 1) { + $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); + $this->errors[$error]['type'] = 'SQL'; $error++; } else { // No record found with filters, insert will be tried below @@ -815,8 +815,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } else { @@ -827,13 +827,13 @@ class ImportCsv extends ModeleImports // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' $sqlSelect = 'SELECT rowid FROM '.$tablename; - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { // We have a row referencing this last foreign key, continue with UPDATE. } else { // No record found referencing this last foreign key, @@ -844,8 +844,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -859,24 +859,24 @@ class ImportCsv extends ModeleImports foreach ($data as $key => $val) { $set[] = $key.' = '.$val; } - $sqlstart.= ' SET '.implode(', ', $set); + $sqlstart .= ' SET '.implode(', ', $set); - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; $sql = $sqlstart.$sqlend; // Run update request - $resql=$this->db->query($sql); - if($resql) { + $resql = $this->db->query($sql); + if ($resql) { // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed $updatedone = true; } else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -887,13 +887,13 @@ class ImportCsv extends ModeleImports // Build SQL INSERT request $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; - if (! empty($tablewithentity_cache[$tablename])) { - $sqlstart.= ', entity'; - $sqlend.= ', '.$conf->entity; + if (!empty($tablewithentity_cache[$tablename])) { + $sqlstart .= ', entity'; + $sqlend .= ', '.$conf->entity; } - if (! empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend.=', '.$user->id; + if (!empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend .= ', '.$user->id; } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_csv.modules", LOG_DEBUG); @@ -901,7 +901,7 @@ class ImportCsv extends ModeleImports // Run insert request if ($sql) { - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). @@ -910,8 +910,8 @@ class ImportCsv extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -926,8 +926,8 @@ class ImportCsv extends ModeleImports if ($error) break; } - if($updatedone) $this->nbupdate++; - if($insertdone) $this->nbinsert++; + if ($updatedone) $this->nbupdate++; + if ($insertdone) $this->nbinsert++; } return 1; @@ -942,5 +942,5 @@ class ImportCsv extends ModeleImports */ function cleansep($value) { - return str_replace(array(',',';'), '/', $value); + return str_replace(array(',', ';'), '/', $value); }; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index c5fcc1441e3..03b3f941a1d 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -25,7 +25,7 @@ * \brief File to load import files with Excel format */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; /** @@ -43,7 +43,7 @@ class ImportXlsx extends ModeleImports /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -60,7 +60,7 @@ class ImportXlsx extends ModeleImports */ public $label; - public $extension; // Extension of files imported by driver + public $extension; // Extension of files imported by driver /** * Dolibarr version of driver @@ -68,19 +68,19 @@ class ImportXlsx extends ModeleImports */ public $version = 'dolibarr'; - public $label_lib; // Label of external lib used by driver + public $label_lib; // Label of external lib used by driver - public $version_lib; // Version of external lib used by driver + public $version_lib; // Version of external lib used by driver public $separator; - public $file; // Path of file + public $file; // Path of file - public $handle; // Handle fichier + public $handle; // Handle fichier - public $cacheconvert=array(); // Array to cache list of value found after a convertion + public $cacheconvert = array(); // Array to cache list of value found after a convertion - public $cachefieldtable=array(); // Array to cache list of value found into fields@tables + public $cachefieldtable = array(); // Array to cache list of value found into fields@tables public $workbook; // temporary import file @@ -97,31 +97,31 @@ class ImportXlsx extends ModeleImports */ public function __construct($db, $datatoimport) { - global $conf,$langs; + global $conf, $langs; $this->db = $db; // this is used as an extension from the example file code, so we have to put xlsx here !!! - $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php - $this->label='Excel 2007'; // Label of driver - $this->desc=$langs->trans("Excel2007FormatDesc"); - $this->extension='xlsx'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) - $this->version='1.0'; // Driver version + $this->id = 'xlsx'; // Same value as xxx in file name export_xxx.modules.php + $this->label = 'Excel 2007'; // Label of driver + $this->desc = $langs->trans("Excel2007FormatDesc"); + $this->extension = 'xlsx'; // Extension for generated file by this driver + $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) + $this->version = '1.0'; // Driver version // If driver use an external library, put its name here require_once PHPEXCEL_PATH.'PHPExcel.php'; require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive + if (!class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive { $langs->load("errors"); - $this->error=$langs->trans('ErrorPHPNeedModule', 'zip'); + $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); return -1; } - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; + $this->label_lib = 'PhpExcel'; + $this->version_lib = '1.8.0'; - $this->datatoimport=$datatoimport; - if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject=new Societe($this->db); + $this->datatoimport = $datatoimport; + if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } @@ -135,11 +135,11 @@ class ImportXlsx extends ModeleImports public function write_header_example($outputlangs) { // phpcs:enable - global $user,$conf,$langs; + global $user, $conf, $langs; // create a temporary object, the final output will be generated in footer if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) { $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; - $cacheSettings = array ( + $cacheSettings = array( 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR ); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); @@ -174,7 +174,7 @@ class ImportXlsx extends ModeleImports $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); $col = 0; - foreach($headerlinefields as $field) { + foreach ($headerlinefields as $field) { $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); // set autowidth //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); @@ -197,7 +197,7 @@ class ImportXlsx extends ModeleImports // phpcs:enable $col = 0; $row = 2; - foreach($contentlinevalues as $cell) { + foreach ($contentlinevalues as $cell) { $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell); $col++; } @@ -240,7 +240,7 @@ class ImportXlsx extends ModeleImports { // phpcs:enable global $langs; - $ret=1; + $ret = 1; dol_syslog(get_class($this)."::open_file file=".$file); @@ -287,7 +287,7 @@ class ImportXlsx extends ModeleImports // This is not called by the import code !!! $this->headers = array(); $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); - for($col=0;$col<$colcount;$col++) { + for ($col = 0; $col < $colcount; $col++) { $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); } return 0; @@ -306,14 +306,14 @@ class ImportXlsx extends ModeleImports global $conf; $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); - if($this->record > $rowcount) + if ($this->record > $rowcount) return false; $array = array(); $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); - for($col=0;$col<$colcount;$col++) { + for ($col = 0; $col < $colcount; $col++) { $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); $array[$col]['val'] = $val; - $array[$col]['type'] = (dol_strlen($val)?1:-1); // If empty we consider it null + $array[$col]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we consider it null } $this->record++; return $array; @@ -349,21 +349,21 @@ class ImportXlsx extends ModeleImports public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable - global $langs,$conf,$user; - global $thirdparty_static; // Specific to thirdparty import - global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables + global $langs, $conf, $user; + global $thirdparty_static; // Specific to thirdparty import + global $tablewithentity_cache; // Cache to avoid to call desc at each rows on tables - $error=0; - $warning=0; - $this->errors=array(); - $this->warnings=array(); + $error = 0; + $warning = 0; + $this->errors = array(); + $this->warnings = array(); //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); //var_dump($array_match_file_to_database); //var_dump($arrayrecord); - $array_match_database_to_file=array_flip($array_match_file_to_database); - $sort_array_match_file_to_database=$array_match_file_to_database; + $array_match_database_to_file = array_flip($array_match_file_to_database); + $sort_array_match_file_to_database = $array_match_file_to_database; ksort($sort_array_match_file_to_database); //var_dump($sort_array_match_file_to_database); @@ -371,8 +371,8 @@ class ImportXlsx extends ModeleImports if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) { //print 'W'; - $this->warnings[$warning]['lib']=$langs->trans('EmptyLine'); - $this->warnings[$warning]['type']='EMPTY'; + $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); + $this->warnings[$warning]['type'] = 'EMPTY'; $warning++; } else @@ -381,25 +381,25 @@ class ImportXlsx extends ModeleImports $updatedone = false; $insertdone = false; // For each table to insert, me make a separate insert - foreach($objimport->array_import_tables[0] as $alias => $tablename) + foreach ($objimport->array_import_tables[0] as $alias => $tablename) { // Build sql request - $sql=''; - $listfields=array(); - $listvalues=array(); - $i=0; - $errorforthistable=0; + $sql = ''; + $listfields = array(); + $listvalues = array(); + $i = 0; + $errorforthistable = 0; // Define $tablewithentity_cache[$tablename] if not already defined - if (! isset($tablewithentity_cache[$tablename])) // keep this test with "isset" + if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" { dol_syslog("Check if table ".$tablename." has an entity field"); - $resql=$this->db->DDLDescTable($tablename, 'entity'); + $resql = $this->db->DDLDescTable($tablename, 'entity'); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field - else $tablewithentity_cache[$tablename]=0; // table does not contains entity field + $obj = $this->db->fetch_object($resql); + if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field + else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field } else dol_print_error($this->db); } @@ -415,26 +415,26 @@ class ImportXlsx extends ModeleImports } // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) - foreach($sort_array_match_file_to_database as $key => $val) + foreach ($sort_array_match_file_to_database as $key => $val) { - $fieldalias=preg_replace('/\..*$/i', '', $val); - $fieldname=preg_replace('/^.*\./i', '', $val); + $fieldalias = preg_replace('/\..*$/i', '', $val); + $fieldname = preg_replace('/^.*\./i', '', $val); - if ($alias != $fieldalias) continue; // Not a field of current table + if ($alias != $fieldalias) continue; // Not a field of current table if ($key <= $maxfields) { // Set $newval with value to insert and set $listvalues with sql request part for insert - $newval=''; - if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value + $newval = ''; + if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval=='')) + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { - $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue', $key); - $this->errors[$error]['type']='NOTNULL'; + $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); + $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; } @@ -442,28 +442,28 @@ class ImportXlsx extends ModeleImports else { // We convert field if required - if (! empty($objimport->array_import_convertvalue[0][$val])) + if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; - if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref' - || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' + if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' + || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' ) { // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. - $isidorref='id'; - if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i', $newval)) $isidorref='ref'; - $newval=preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref + $isidorref = 'id'; + if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; + $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
        \n"; if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') { - $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; + $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; } else { @@ -473,7 +473,7 @@ class ImportXlsx extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') @@ -577,11 +577,11 @@ class ImportXlsx extends ModeleImports dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); - $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; if ($classinstance->id > 0) // we found record { @@ -589,91 +589,91 @@ class ImportXlsx extends ModeleImports } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); - $newval=$this->thirpartyobject->code_client; + $newval = $this->thirpartyobject->code_client; //print 'code_client='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { - $newval=$this->thirpartyobject->get_codefournisseur(0, 1); - $newval=$this->thirpartyobject->code_fournisseur; + $newval = $this->thirpartyobject->get_codefournisseur(0, 1); + $newval = $this->thirpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); - $newval=$this->thirpartyobject->code_compta; + $newval = $this->thirpartyobject->code_compta; //print 'code_compta='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); - $newval=$this->thirpartyobject->code_compta_fournisseur; - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + $newval = $this->thirpartyobject->code_compta_fournisseur; + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" //print 'code_compta_fournisseur='.$newval; } - if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" + if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { - $defaultref=''; + $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(null, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; - $newval=$defaultref; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; + $newval = $defaultref; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { - $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); - $class=$objimport->array_import_convertvalue[0][$val]['class']; - $method=$objimport->array_import_convertvalue[0][$val]['method']; + $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); + $class = $objimport->array_import_convertvalue[0][$val]['class']; + $method = $objimport->array_import_convertvalue[0][$val]['method']; $resultload = dol_include_once($file); if (empty($resultload)) { dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); break; } - $classinstance=new $class($this->db); + $classinstance = new $class($this->db); $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); - if ($res<0) { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; - $this->errors[$error]['type']='FOREIGNKEY'; + if ($res < 0) { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } @@ -682,36 +682,36 @@ class ImportXlsx extends ModeleImports } // Test regexp - if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { - $field=$reg[1]; - $table=$reg[2]; - $filter=!empty($reg[3])?substr($reg[3], 1):''; + $field = $reg[1]; + $table = $reg[2]; + $filter = !empty($reg[3]) ?substr($reg[3], 1) : ''; $cachekey = $field.'@'.$table; - if(! empty($filter)) $cachekey.= ':'.$filter; + if (!empty($filter)) $cachekey .= ':'.$filter; // Load content of field@table into cache array - if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache + if (!is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { - $sql="SELECT ".$field." as aliasfield FROM ".$table; - if(! empty($filter)) + $sql = "SELECT ".$field." as aliasfield FROM ".$table; + if (!empty($filter)) { - $sql.= ' WHERE ' . $filter; + $sql .= ' WHERE '.$filter; } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield; + $obj = $this->db->fetch_object($resql); + if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield; $i++; } } @@ -722,21 +722,21 @@ class ImportXlsx extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey])) + if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; - if(! empty($filter)) $tableforerror.= ':'.$filter; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); - $this->errors[$error]['type']='FOREIGNKEY'; + if (!empty($filter)) $tableforerror .= ':'.$filter; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); + $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; } } // If test is just a static regex - elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
        "; - $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); - $this->errors[$error]['type']='REGEX'; + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); + $this->errors[$error]['type'] = 'REGEX'; $errorforthistable++; $error++; } @@ -750,8 +750,8 @@ class ImportXlsx extends ModeleImports $listfields[] = $fieldname; // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; + if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null"); + elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) $listvalues[] = "''"; else $listvalues[] = "'".$this->db->escape($newval)."'"; } $i++; @@ -761,9 +761,9 @@ class ImportXlsx extends ModeleImports if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach($objimport->array_import_fieldshidden[0] as $key => $val) + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table + if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); @@ -771,8 +771,8 @@ class ImportXlsx extends ModeleImports } elseif (preg_match('/^lastrowid-/', $val)) { - $tmp=explode('-', $val); - $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; + $tmp = explode('-', $val); + $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; @@ -780,14 +780,14 @@ class ImportXlsx extends ModeleImports } elseif (preg_match('/^const-/', $val)) { - $tmp=explode('-', $val, 2); + $tmp = explode('-', $val, 2); $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listvalues[] = "'".$tmp[1]."'"; } else { - $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden'; - $this->errors[$error]['type']='Import profile setup'; + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['type'] = 'Import profile setup'; $error++; } } @@ -796,7 +796,7 @@ class ImportXlsx extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined // so we can try to make the insert or update now. - if (! $errorforthistable) + if (!$errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
        "; if (!empty($listfields)) @@ -814,21 +814,21 @@ class ImportXlsx extends ModeleImports $filters = array(); foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; - $key=preg_replace('/^.*\./i', '', $key); + $key = preg_replace('/^.*\./i', '', $key); $where[] = $key.' = '.$data[$key]; $filters[] = $col.' = '.$data[$key]; } - $sqlSelect.= ' WHERE '.implode(' AND ', $where); + $sqlSelect .= ' WHERE '.implode(' AND ', $where); - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; - } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); - $this->errors[$error]['type']='SQL'; + } elseif ($resql->num_rows > 1) { + $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); + $this->errors[$error]['type'] = 'SQL'; $error++; } else { // No record found with filters, insert will be tried below @@ -837,8 +837,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } else { @@ -849,13 +849,13 @@ class ImportXlsx extends ModeleImports // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' $sqlSelect = 'SELECT rowid FROM '.$tablename; - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; - $resql=$this->db->query($sqlSelect); - if($resql) { + $resql = $this->db->query($sqlSelect); + if ($resql) { $res = $this->db->fetch_object($resql); - if($resql->num_rows == 1) { + if ($resql->num_rows == 1) { // We have a row referencing this last foreign key, continue with UPDATE. } else { // No record found referencing this last foreign key, @@ -866,8 +866,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -881,24 +881,24 @@ class ImportXlsx extends ModeleImports foreach ($data as $key => $val) { $set[] = $key.' = '.$val; } - $sqlstart.= ' SET '.implode(', ', $set); + $sqlstart .= ' SET '.implode(', ', $set); - if(empty($keyfield)) $keyfield = 'rowid'; + if (empty($keyfield)) $keyfield = 'rowid'; $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; $sql = $sqlstart.$sqlend; // Run update request - $resql=$this->db->query($sql); - if($resql) { + $resql = $this->db->query($sql); + if ($resql) { // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed $updatedone = true; } else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -909,13 +909,13 @@ class ImportXlsx extends ModeleImports // Build SQL INSERT request $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; - if (! empty($tablewithentity_cache[$tablename])) { - $sqlstart.= ', entity'; - $sqlend.= ', '.$conf->entity; + if (!empty($tablewithentity_cache[$tablename])) { + $sqlstart .= ', entity'; + $sqlend .= ', '.$conf->entity; } - if (! empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend.=', '.$user->id; + if (!empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend .= ', '.$user->id; } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_xlsx.modules", LOG_DEBUG); @@ -923,7 +923,7 @@ class ImportXlsx extends ModeleImports // Run insert request if ($sql) { - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). @@ -932,8 +932,8 @@ class ImportXlsx extends ModeleImports else { //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; + $this->errors[$error]['lib'] = $this->db->lasterror(); + $this->errors[$error]['type'] = 'SQL'; $error++; } } @@ -948,8 +948,8 @@ class ImportXlsx extends ModeleImports if ($error) break; } - if($updatedone) $this->nbupdate++; - if($insertdone) $this->nbinsert++; + if ($updatedone) $this->nbupdate++; + if ($insertdone) $this->nbinsert++; } return 1; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b6a9f968a02..b15bd41f9bb 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -29,7 +29,7 @@ * \ingroup produit * \brief File to describe module to manage catalog of predefined products */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -59,25 +59,25 @@ class modProduct extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='product'; + $this->picto = 'product'; // Data directories to create when module is enabled $this->dirs = array("/product/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock","modBarcode","modProductBatch","modVariants"); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","stocks","bills"); + $this->langfiles = array("products", "companies", "stocks", "bills"); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "PRODUCT_CODEPRODUCT_ADDON"; $this->const[$r][1] = "chaine"; @@ -102,15 +102,15 @@ class modProduct extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_produits_alerte_stock.php','enabledbydefaulton'=>''), - 2=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_produits.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_produits_alerte_stock.php', 'enabledbydefaulton'=>''), + 2=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') ); // Permissions $this->rights = array(); $this->rights_class = 'produit'; - $r=0; + $r = 0; $this->rights[$r][0] = 31; // id de la permission $this->rights[$r][1] = 'Read products'; // libelle de la permission @@ -133,7 +133,7 @@ class modProduct extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - $this->rights[$r][0] = 38; // Must be same permission than in service module + $this->rights[$r][0] = 38; // Must be same permission than in service module $this->rights[$r][1] = 'Export products'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -150,7 +150,7 @@ class modProduct extends DolibarrModules // Menus //------- - $this->menu = 1; // This module adds menu entries. They are coded into menu manager. + $this->menu = 1; // This module adds menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -398,28 +398,28 @@ class modProduct extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.duration' => "Duration",//duration of service + 'p.duration' => "Duration", //duration of service 'p.finished' => 'Nature', - 'p.price' => "SellingPriceHT",//without + 'p.price' => "SellingPriceHT", //without 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_ttc' => "SellingPriceTTC", //with tax 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card 'p.tva_tx' => 'VATRate', 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning - 'p.pmp' => 'PMPValue',//weighted average price + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -427,7 +427,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -435,7 +435,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -443,7 +443,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -451,7 +451,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -459,7 +459,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -475,29 +475,29 @@ class modProduct extends DolibarrModules ) ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields - $import_extrafield_sample=array(); - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; - $resql=$this->db->query($sql); + $import_extrafield_sample = array(); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - $import_extrafield_sample[$fieldname]=$fieldlabel; + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( 'p.ref' => '[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell' => '^[0|1]$', @@ -523,7 +523,7 @@ class modProduct extends DolibarrModules 'p.price_ttc' => "110", 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -534,17 +534,17 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array @@ -553,16 +553,16 @@ class modProduct extends DolibarrModules 'p.pmp' => '0', 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); - if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $import_sample = array_merge( $import_sample, array( - 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' ) ); @@ -577,21 +577,21 @@ class modProduct extends DolibarrModules ) )); } - $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; - $this->import_code[$r]=$this->rights_class.'_supplierprices'; - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + $this->import_code[$r] = $this->rights_class.'_supplierprices'; + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); + $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", 'sp.ref_fourn' => 'SupplierRef', @@ -601,19 +601,19 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => 'DeliveryDelay', 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); if ($conf->multicurrency->enabled) { - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', @@ -621,12 +621,12 @@ class modProduct extends DolibarrModules )); } - $this->import_convertvalue_array[$r]=array( - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array( + $this->import_examplevalues_array[$r] = array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", @@ -639,9 +639,9 @@ class modProduct extends DolibarrModules 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.price' => "50.00", 'sp.unitprice' => '10', @@ -650,7 +650,7 @@ class modProduct extends DolibarrModules )); if ($conf->multicurrency->enabled) { - $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_tx'=>'1.12345', @@ -660,32 +660,32 @@ class modProduct extends DolibarrModules )); } - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Import products multiprices $r++; - $this->import_code[$r]=$this->rights_class.'_multiprice'; - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->import_code[$r] = $this->rights_class.'_multiprice'; + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); - $this->import_convertvalue_array[$r]=array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); + $this->import_convertvalue_array[$r] = array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"PRODUCT_REF or id:123456", - 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', @@ -693,23 +693,23 @@ class modProduct extends DolibarrModules 'pr.date_price'=>'2013-04-10'); } - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // Import translations of product names and descriptions $r++; - $this->import_code[$r]=$this->rights_class.'_languages'; - $this->import_label[$r]="ProductsOrServicesTranslations"; - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); + $this->import_code[$r] = $this->rights_class.'_languages'; + $this->import_label[$r] = "ProductsOrServicesTranslations"; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; - $this->import_convertvalue_array[$r]=array( - 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'PRODUCT_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 780a9078f2b..379799a0ac6 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -26,7 +26,7 @@ * \ingroup service * \brief Fichier de description et activation du module Service */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -57,35 +57,35 @@ class modService extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto='service'; + $this->picto = 'service'; // Data directories to create when module is enabled $this->dirs = array("/product/temp"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with - $this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->phpmin = array(5, 4); // Minimum version of PHP required by module // Config pages $this->config_page_url = array("product.php@product"); - $this->langfiles = array("products","companies","stocks","bills"); + $this->langfiles = array("products", "companies", "stocks", "bills"); // Constants $this->const = array(); // Boxes $this->boxes = array( - 0=>array('file'=>'box_services_contracts.php','enabledbydefaulton'=>'Home'), - 1=>array('file'=>'box_graph_product_distribution.php','enabledbydefaulton'=>'Home') + 0=>array('file'=>'box_services_contracts.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_graph_product_distribution.php', 'enabledbydefaulton'=>'Home') ); // Permissions $this->rights = array(); $this->rights_class = 'service'; - $r=0; + $r = 0; $this->rights[$r][0] = 531; // id de la permission $this->rights[$r][1] = 'Read services'; // libelle de la permission @@ -108,7 +108,7 @@ class modService extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - $this->rights[$r][0] = 538; // Must be same permission than in product module + $this->rights[$r][0] = 538; // Must be same permission than in product module $this->rights[$r][1] = 'Export services'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -117,7 +117,7 @@ class modService extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -367,28 +367,28 @@ class modService extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.duration' => "Duration",//duration of service + 'p.duration' => "Duration", //duration of service 'p.finished' => 'Nature', - 'p.price' => "SellingPriceHT",//without + 'p.price' => "SellingPriceHT", //without 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_ttc' => "SellingPriceTTC", //with tax 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card 'p.tva_tx' => 'VATRate', 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning - 'p.pmp' => 'PMPValue',//weighted average price + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -396,7 +396,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -404,7 +404,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -412,7 +412,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -420,7 +420,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -428,7 +428,7 @@ class modService extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -443,29 +443,29 @@ class modService extends DolibarrModules 'dict' => 'DictionaryCountry' ) ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (!empty($conf->barcode->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields - $import_extrafield_sample=array(); - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); + $import_extrafield_sample = array(); + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - $import_extrafield_sample[$fieldname]=$fieldlabel; + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; } } // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( + $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r] = array( 'p.ref'=>'[^ ]', 'p.price_base_type' => '\AHT\z|\ATTC\z', 'p.tosell'=>'^[0|1]$', @@ -490,7 +490,7 @@ class modService extends DolibarrModules 'p.price_ttc' => "110", 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -501,17 +501,17 @@ class modService extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array @@ -520,16 +520,16 @@ class modService extends DolibarrModules 'p.pmp' => '0', 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); - if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>'')); + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $import_sample = array_merge( $import_sample, array( - 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"' ) ); @@ -544,23 +544,23 @@ class modService extends DolibarrModules ) )); } - $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); + $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); - if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled + if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { // Import suppliers prices (note: this code is duplicated in module Service) $r++; - $this->import_code[$r]=$this->rights_class.'_supplierprices'; - $this->import_label[$r]="SuppliersPricesOfProductsOrServices"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); - $this->import_tables_creator_array[$r]=array('sp'=>'fk_user'); - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product_fournisseur_price, without optional fields + $this->import_code[$r] = $this->rights_class.'_supplierprices'; + $this->import_label[$r] = "SuppliersPricesOfProductsOrServices"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price'); + $this->import_tables_creator_array[$r] = array('sp'=>'fk_user'); + $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", 'sp.ref_fourn' => 'SupplierRef', @@ -570,19 +570,19 @@ class modService extends DolibarrModules 'sp.delivery_time_days' => 'DeliveryDelay', 'sp.supplier_reputation' => 'SupplierReputation' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' )); if ($conf->multicurrency->enabled) { - $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( - 'sp.fk_multicurrency'=>'CurrencyCodeId',//ideally this should be automatically obtained from the CurrencyCode on the next line + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line 'sp.multicurrency_code'=>'CurrencyCode', 'sp.multicurrency_tx'=>'CurrencyRate', 'sp.multicurrency_unitprice'=>'CurrencyUnitPrice', @@ -590,11 +590,11 @@ class modService extends DolibarrModules )); } - $this->import_convertvalue_array[$r]=array( - 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), - 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), + 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array( + $this->import_examplevalues_array[$r] = array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", @@ -607,9 +607,9 @@ class modService extends DolibarrModules 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.price' => "50.00", 'sp.unitprice' => '10', @@ -618,7 +618,7 @@ class modService extends DolibarrModules )); if ($conf->multicurrency->enabled) { - $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', 'sp.multicurrency_code'=>'GBP', 'sp.multicurrency_tx'=>'1.12345', @@ -628,56 +628,56 @@ class modService extends DolibarrModules )); } - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } - if (! empty($conf->global->PRODUIT_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { // Import products multiprices $r++; - $this->import_code[$r]=$this->rights_class.'_multiprice'; - $this->import_label[$r]="ProductsOrServiceMultiPrice"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); - $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", - 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", - 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", - 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", + $this->import_code[$r] = $this->rights_class.'_multiprice'; + $this->import_label[$r] = "ProductsOrServiceMultiPrice"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('pr'=>MAIN_DB_PREFIX.'product_price'); + $this->import_tables_creator_array[$r] = array('pr'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r] = array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", + 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", + 'pr.price_min'=>"MinPriceLevelUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.date_price'=>'DateCreation*'); - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); - $this->import_convertvalue_array[$r]=array( - 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx'] = 'VATRate'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); + $this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$'); + $this->import_convertvalue_array[$r] = array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"SERVICE_REF or id:123456", - 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", - 'pr.price'=>"100",'pr.price_ttc'=>"110", - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", + 'pr.price'=>"100", 'pr.price_ttc'=>"110", + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', 'pr.recuperableonly'=>'0', 'pr.date_price'=>'2013-04-10'); } - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { // Import translations of product names and descriptions $r++; - $this->import_code[$r]=$this->rights_class.'_languages'; - $this->import_label[$r]="ProductsOrServicesTranslations"; - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); + $this->import_code[$r] = $this->rights_class.'_languages'; + $this->import_label[$r] = "ProductsOrServicesTranslations"; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; - $this->import_convertvalue_array[$r]=array( - 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + $this->import_convertvalue_array[$r] = array( + 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'SERVICE_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 6883a089bda..9029fc82dfc 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -37,16 +37,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; /** @@ -88,32 +88,32 @@ class doc_generic_project_odt extends ModelePDFProjects $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -131,7 +131,7 @@ class doc_generic_project_odt extends ModelePDFProjects // phpcs:enable global $conf; - $resarray=array( + $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_title'=>$object->title, @@ -209,7 +209,7 @@ class doc_generic_project_odt extends ModelePDFProjects { // phpcs:enable global $conf; - $pc='projcontacts_'; // prefix to avoid typos + $pc = 'projcontacts_'; // prefix to avoid typos $ret = array( $pc.'id'=>$contact['id'], @@ -223,7 +223,7 @@ class doc_generic_project_odt extends ModelePDFProjects $pc.'email'=>$contact['email'] ); - if ($contact['source']=='external') { + if ($contact['source'] == 'external') { $ret[$pc.'isInternal'] = ''; // not internal $ct = new Contact($this->db); @@ -234,15 +234,15 @@ class doc_generic_project_odt extends ModelePDFProjects // fetch external user extrafields require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($ct->table_element, true); $extrafields_num = $ct->fetch_optionals(); //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG); - foreach($ct->array_options as $efkey => $efval) { + foreach ($ct->array_options as $efkey => $efval) { dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG); $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX' } - } elseif ($contact['source']=='internal') { + } elseif ($contact['source'] == 'internal') { $ret[$pc.'isInternal'] = '1'; // this is an internal user $ct = new User($this->db); @@ -381,83 +381,83 @@ class doc_generic_project_odt extends ModelePDFProjects */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("companies","errors")); + $langs->loadLangs(array("companies", "errors")); $form = new Form($this->db); $texte = $this->description.".
        \n"; - $texte.= '
        '; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
        '; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
        '; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
        '; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
        '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
        '; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
        '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
        '; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
        '; - $texte.= ''; - $texte.= '
        '; - $texte.= ''; - $texte.= '
        '; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
        '; + $texte .= ''; + $texte .= '
        '; + $texte .= ''; + $texte .= '
        '; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
        '; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
        '; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
        '; - $texte.= '
        '; + $texte .= ''; + $texte .= ''; return $texte; } @@ -474,7 +474,7 @@ class doc_generic_project_odt extends ModelePDFProjects public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -483,17 +483,17 @@ class doc_generic_project_odt extends ModelePDFProjects } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -501,11 +501,11 @@ class doc_generic_project_odt extends ModelePDFProjects if ($conf->projet->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Project($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -515,14 +515,14 @@ class doc_generic_project_odt extends ModelePDFProjects $dir = $conf->projet->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -530,25 +530,25 @@ class doc_generic_project_odt extends ModelePDFProjects if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -557,33 +557,33 @@ class doc_generic_project_odt extends ModelePDFProjects dol_mkdir($conf->projet->dir_temp); // If PROJECTLEADER contact defined on project, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'PROJECTLEADER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Open and load template require_once ODTPHP_PATH.'odf.php'; @@ -592,13 +592,13 @@ class doc_generic_project_odt extends ModelePDFProjects $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -612,23 +612,23 @@ class doc_generic_project_odt extends ModelePDFProjects // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_project_contact = array(); - if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -655,43 +655,43 @@ class doc_generic_project_odt extends ModelePDFProjects $taskstatic = new Task($this->db); // Security check - $socid=0; + $socid = 0; if (!empty($object->fk_soc)) $socid = $object->fk_soc; - $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); foreach ($tasksarray as $task) { - $tmparray=$this->get_substitutionarray_tasks($task, $outputlangs); + $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs); //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines"); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } - $taskobj=new Task($this->db); + $taskobj = new Task($this->db); $taskobj->fetch($task->id); // Replace tags of lines for contacts task - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$taskobj->liste_contact(-1, $source); + $contact_temp = $taskobj->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -700,33 +700,33 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_tasksressource($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -737,7 +737,7 @@ class doc_generic_project_odt extends ModelePDFProjects //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname, t.thm"; + $sql .= ", u.lastname, u.firstname, t.thm"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$task->id; @@ -750,33 +750,33 @@ class doc_generic_project_odt extends ModelePDFProjects $num = $this->db->num_rows($resql); $i = 0; $tasks = array(); - $row=array(); + $row = array(); $listlinestasktime = $listlines->__get('taskstimes'); if (empty($num)) { - $row['rowid']=''; - $row['task_date']=''; - $row['task_duration']=''; - $row['$tasktime']=''; - $row['note']=''; - $row['fk_user']=''; - $row['name']=''; - $row['firstname']=''; - $row['fullcivname']=''; - $row['amountht']=''; - $row['amountttc']=''; - $row['thm']=''; - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + $row['rowid'] = ''; + $row['task_date'] = ''; + $row['task_duration'] = ''; + $row['$tasktime'] = ''; + $row['note'] = ''; + $row['fk_user'] = ''; + $row['name'] = ''; + $row['firstname'] = ''; + $row['fullcivname'] = ''; + $row['amountht'] = ''; + $row['amountttc'] = ''; + $row['thm'] = ''; + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -787,36 +787,36 @@ class doc_generic_project_odt extends ModelePDFProjects { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { - $objectdetail=new User($this->db); + $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); - $row['fullcivname']=$objectdetail->getFullName($outputlangs, 1); + $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { - $row['fullcivname']=''; + $row['fullcivname'] = ''; } if (!empty($row['thm'])) { - $row['amountht']=($row['task_duration'] / 3600) * $row['thm']; + $row['amountht'] = ($row['task_duration'] / 3600) * $row['thm']; $defaultvat = get_default_tva($mysoc, $mysoc); - $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT'); + $row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT'); } else { - $row['amountht']=0; - $row['amountttc']=0; - $row['thm']=0; + $row['amountht'] = 0; + $row['amountttc'] = 0; + $row['thm'] = 0; } - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -832,14 +832,14 @@ class doc_generic_project_odt extends ModelePDFProjects $listtasksfiles = $listlines->__get('tasksfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { - $tmparray=$this->get_substitutionarray_task_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { @@ -860,13 +860,13 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $ExceptionTrace=$e->getTrace(); + $ExceptionTrace = $e->getTrace(); // no segment defined on ODT is not an error - if($ExceptionTrace[0]['function'] != 'setSegment') + if ($ExceptionTrace[0]['function'] != 'setSegment') { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -878,24 +878,24 @@ class doc_generic_project_odt extends ModelePDFProjects $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); - $tmparray=$this->get_substitutionarray_project_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -904,21 +904,21 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$object->liste_contact(-1, $source); + $contact_temp = $object->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -929,32 +929,32 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_project_contacts($contact, $outputlangs); - foreach($tmparray as $key => $val) + $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -963,9 +963,9 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -1065,14 +1065,14 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListSocialContributionAssociatedProject", 'class' => 'ChargeSociales', 'table' => 'chargesociales', - 'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id, + 'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id, 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire ), 'stock_mouvement' => array( 'title' => "ListMouvementStockProject", 'class' => 'MouvementStock', 'table' => 'stock_mouvement', - 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) ), 'agenda' => array( 'title' => "ListActionsAssociatedProject", @@ -1090,72 +1090,72 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($listofreferent as $keyref => $valueref) { - $title=$valueref['title']; - $tablename=$valueref['table']; - $classname=$valueref['class']; - $qualified=$valueref['test']; + $title = $valueref['title']; + $tablename = $valueref['table']; + $classname = $valueref['class']; + $qualified = $valueref['test']; if ($qualified) { $elementarray = $object->get_element_list($keyref, $tablename); - if (count($elementarray)>0 && is_array($elementarray)) + if (count($elementarray) > 0 && is_array($elementarray)) { $total_ht = 0; $total_ttc = 0; - $num=count($elementarray); + $num = count($elementarray); for ($i = 0; $i < $num; $i++) { - $ref_array=array(); - $ref_array['type']=$langs->trans($classname); + $ref_array = array(); + $ref_array['type'] = $langs->trans($classname); $element = new $classname($this->db); $element->fetch($elementarray[$i]); $element->fetch_thirdparty(); //Ref object - $ref_array['ref']=$element->ref; + $ref_array['ref'] = $element->ref; //Date object - $dateref=$element->date; - if (empty($dateref)) $dateref=$element->datep; - if (empty($dateref)) $dateref=$element->date_contrat; - $ref_array['date']=$dateref; + $dateref = $element->date; + if (empty($dateref)) $dateref = $element->datep; + if (empty($dateref)) $dateref = $element->date_contrat; + $ref_array['date'] = $dateref; //Soc object if (is_object($element->thirdparty)) { - $ref_array['socname']=$element->thirdparty->name; + $ref_array['socname'] = $element->thirdparty->name; } else { - $ref_array['socname']=''; + $ref_array['socname'] = ''; } //Amount object if (empty($valueref['disableamount'])) { if (!empty($element->total_ht)) { - $ref_array['amountht']=$element->total_ht; - $ref_array['amountttc']=$element->total_ttc; + $ref_array['amountht'] = $element->total_ht; + $ref_array['amountttc'] = $element->total_ttc; } else { - $ref_array['amountht']=0; - $ref_array['amountttc']=0; + $ref_array['amountht'] = 0; + $ref_array['amountttc'] = 0; } } else { - $ref_array['amountht']=''; - $ref_array['amountttc']=''; + $ref_array['amountht'] = ''; + $ref_array['amountttc'] = ''; } - $ref_array['status']=$element->getLibStatut(0); + $ref_array['status'] = $element->getLibStatut(0); - $tmparray=$this->get_substitutionarray_project_reference($ref_array, $outputlangs); + $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -1166,15 +1166,15 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } - } catch(OdfException $e) { - $this->error=$e->getMessage(); + } catch (OdfException $e) { + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -1184,8 +1184,8 @@ class doc_generic_project_odt extends ModelePDFProjects } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file @@ -1193,33 +1193,33 @@ class doc_generic_project_odt extends ModelePDFProjects try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } else { try { $odfHandler->saveToDisk($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index 8abcc41c263..6251f02a0de 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -24,7 +24,7 @@ * \brief File to manage no password generation. */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; /** @@ -75,10 +75,10 @@ class modGeneratePassPerso extends ModeleGenPassword $this->id = "Perso"; $this->length = $langs->trans("SetupPerso"); - $this->db=$db; - $this->conf=$conf; - $this->langs=$langs; - $this->user=$user; + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; if (empty($conf->global->USER_PASSWORD_PATTERN)) { // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. @@ -89,7 +89,7 @@ class modGeneratePassPerso extends ModeleGenPassword $this->Min = strtolower($this->Maj); $this->Nb = "0123456789"; $this->Spe = "!@#$%&*()_-+={}[]\\|:;'/"; - $this->Ambi = array("1","I","l","|","O","0"); + $this->Ambi = array("1", "I", "l", "|", "O", "0"); $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); $this->length2 = $tabConf[0]; @@ -107,7 +107,7 @@ class modGeneratePassPerso extends ModeleGenPassword $this->Spe = str_replace($this->Ambi, "", $this->Spe); } - $pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:''); + $pattern = $this->Min.(!empty($this->NbMaj) ? $this->Maj : '').(!empty($this->NbNum) ? $this->Nb : '').(!empty($this->NbSpe) ? $this->Spe : ''); $this->All = str_shuffle($pattern); //$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe); @@ -144,24 +144,24 @@ class modGeneratePassPerso extends ModeleGenPassword public function getNewGeneratedPassword() { $pass = ""; - for ($i=0; $i<$this->NbMaj; $i++) { + for ($i = 0; $i < $this->NbMaj; $i++) { // Y $pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)]; } - for ($i=0; $i<$this->NbNum; $i++) { + for ($i = 0; $i < $this->NbNum; $i++) { // X $pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)]; } - for ($i=0; $i<$this->NbSpe; $i++) { + for ($i = 0; $i < $this->NbSpe; $i++) { // @ $pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)]; } - for ($i=strlen($pass);$i<$this->length2; $i++) { + for ($i = strlen($pass); $i < $this->length2; $i++) { // y - $pass .= $this->All[mt_rand(0, strlen($this->All) -1)]; + $pass .= $this->All[mt_rand(0, strlen($this->All) - 1)]; } $pass = str_shuffle($pass); @@ -220,8 +220,8 @@ class modGeneratePassPerso extends ModeleGenPassword $count = 0; $char = str_split($password); - foreach($char as $c) { - if($c != $last) { + foreach ($char as $c) { + if ($c != $last) { $last = $c; $count = 0; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 9adc6afad9d..4f59c2510b4 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -117,7 +117,7 @@ class pdf_stdmovement extends ModelePDFMovement */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Load traductions files required by page $langs->loadLangs(array("main", "companies")); @@ -128,54 +128,54 @@ class pdf_stdmovement extends ModelePDFMovement // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_codestockservice = 0; // Affiche code stock-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_freetext = 0; // Support add of a personalised text + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined // Define position of columns $this->wref = 15; $this->posxidref = $this->marge_gauche; - $this->posxdatemouv = $this->marge_gauche+8; - $this->posxdesc=37; - $this->posxlabel=50; - $this->posxtva=80; - $this->posxqty=105; - $this->posxup=119; - $this->posxunit=136; - $this->posxdiscount=167; - $this->postotalht=180; + $this->posxdatemouv = $this->marge_gauche + 8; + $this->posxdesc = 37; + $this->posxlabel = 50; + $this->posxtva = 80; + $this->posxqty = 105; + $this->posxup = 119; + $this->posxunit = 136; + $this->posxdiscount = 167; + $this->postotalht = 180; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup; + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } @@ -194,11 +194,11 @@ class pdf_stdmovement extends ModelePDFMovement public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager; + global $user, $langs, $conf, $mysoc, $db, $hookmanager; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); @@ -207,13 +207,13 @@ class pdf_stdmovement extends ModelePDFMovement * TODO: get from object */ - $id=GETPOST('id', 'int'); + $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); - $msid=GETPOST('msid', 'int'); - $product_id=GETPOST("product_id"); - $action=GETPOST('action', 'aZ09'); - $cancel=GETPOST('cancel', 'alpha'); - $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; + $msid = GETPOST('msid', 'int'); + $product_id = GETPOST("product_id"); + $action = GETPOST('action', 'aZ09'); + $cancel = GETPOST('cancel', 'alpha'); + $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); @@ -227,18 +227,18 @@ class pdf_stdmovement extends ModelePDFMovement $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); - $search_type_mouvement=GETPOST('search_type_mouvement', 'int'); + $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; - if (! $sortfield) $sortfield="m.datem"; - if (! $sortorder) $sortorder="DESC"; + if (!$sortfield) $sortfield = "m.datem"; + if (!$sortorder) $sortorder = "DESC"; - $pdluoid=GETPOST('pdluoid', 'int'); + $pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('movementlist')); @@ -324,7 +324,7 @@ class pdf_stdmovement extends ModelePDFMovement } } - if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset); + if (empty($search_inventorycode)) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -358,44 +358,44 @@ class pdf_stdmovement extends ModelePDFMovement $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } } // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->stock->dir_output . "/movement"; - $file = $dir . "/SPECIMEN.pdf"; + $dir = $conf->stock->dir_output."/movement"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; - if($search_type_mouvement) $objectref.="_".$search_type_mouvement; - $dir = $conf->stock->dir_output . "/movement/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; + if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + $dir = $conf->stock->dir_output."/movement/".$objectref; + $file = $dir."/".$objectref.".pdf"; } $stockFournisseur = new ProductFournisseur($this->db); $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); $object->supplierprices = $supplierprices; - $productstatic=new Product($db); + $productstatic = new Product($db); - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -403,24 +403,24 @@ class pdf_stdmovement extends ModelePDFMovement if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { @@ -429,14 +429,14 @@ class pdf_stdmovement extends ModelePDFMovement } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -469,12 +469,12 @@ class pdf_stdmovement extends ModelePDFMovement /* */ /* ************************************************************************** */ - $nexY+=5; + $nexY += 5; $nexY = $pdf->GetY(); - $nexY+=10; + $nexY += 10; - $totalunit=0; - $totalvalue=$totalvaluesell=0; + $totalunit = 0; + $totalvalue = $totalvaluesell = 0; $arrayofuniqueproduct = array(); //dol_syslog('List products', LOG_DEBUG); @@ -484,18 +484,18 @@ class pdf_stdmovement extends ModelePDFMovement $num = $db->num_rows($resql); $i = 0; $nblines = $num; - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $objp = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) @@ -599,60 +599,60 @@ class pdf_stdmovement extends ModelePDFMovement // Id movement. $pdf->SetXY($this->posxidref, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0, 'L'); // Date. $pdf->SetXY($this->posxdatemouv, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6, dol_print_date($db->jdate($objp->datem), 'dayhour'), 0, 'L'); // Ref. $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L'); + $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0, 'L'); // Label - $pdf->SetXY($this->posxlabel+0.8, $curY); - $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L'); + $pdf->SetXY($this->posxlabel + 0.8, $curY); + $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0, 'L'); // Lot/serie $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R'); + $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0, 'R'); // Inv. code $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R'); + $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0, 'R'); // Label mouvement $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R'); - $totalvalue+=price2num($objp->ppmp*$objp->value, 'MT'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0, 'R'); + $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); // Origin - $pricemin=$objp->price; + $pricemin = $objp->price; $pdf->SetXY($this->posxdiscount, $curY); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0); + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0, 'R', 0); // Qty - $valtoshow=price2num($objp->qty, 'MS'); - $towrite = (empty($valtoshow)?'0':$valtoshow); - $totalunit+=$objp->qty; + $valtoshow = price2num($objp->qty, 'MS'); + $towrite = (empty($valtoshow) ? '0' : $valtoshow); + $totalunit += $objp->qty; $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0, 'R', 0); - $totalvaluesell+=price2num($pricemin*$objp->value, 'MT'); + $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); - $nexY+=3.5; // Add space between lines + $nexY += 3.5; // Add space between lines // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -669,10 +669,10 @@ class pdf_stdmovement extends ModelePDFMovement $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -685,7 +685,7 @@ class pdf_stdmovement extends ModelePDFMovement $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -697,23 +697,23 @@ class pdf_stdmovement extends ModelePDFMovement * footer table */ $nexY = $pdf->GetY(); - $nexY+=5; + $nexY += 5; $curY = $nexY; - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); - $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); + $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1); $pdf->SetLineStyle(array('dash'=>0)); - $pdf->SetFont('', 'B', $default_font_size-1); + $pdf->SetFont('', 'B', $default_font_size - 1); $pdf->SetTextColor(0, 0, 120); // Total $pdf->SetXY($this->posxidref, $curY); - $pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans("Total"), 0, 'L'); // Total Qty $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0, 'R', 0); } else { @@ -722,7 +722,7 @@ class pdf_stdmovement extends ModelePDFMovement if ($notetoshow) { - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -730,41 +730,41 @@ class pdf_stdmovement extends ModelePDFMovement $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage+21; + $tab_top = $tab_top_newpage + 21; // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; // Affiche zone infos //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); @@ -782,31 +782,31 @@ class pdf_stdmovement extends ModelePDFMovement // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); return 0; } } @@ -830,8 +830,8 @@ class pdf_stdmovement extends ModelePDFMovement global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -843,11 +843,11 @@ class pdf_stdmovement extends ModelePDFMovement if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); @@ -856,9 +856,9 @@ class pdf_stdmovement extends ModelePDFMovement // Output Rect //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); $pdf->SetDrawColor(220, 26, 26); - $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top); $pdf->SetLineStyle(array('dash'=>0)); $pdf->SetDrawColor(128, 128, 128); $pdf->SetTextColor(0, 0, 120); @@ -867,32 +867,32 @@ class pdf_stdmovement extends ModelePDFMovement if (empty($hidetop)) { //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxidref, $tab_top+1); - $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); + $pdf->SetXY($this->posxidref, $tab_top + 1); + $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); } //Date mouv //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdatemouv, $tab_top+1); - $pdf->MultiCell($this->posxdesc-$this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C'); + $pdf->SetXY($this->posxdatemouv, $tab_top + 1); + $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C'); } //Ref Product //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdesc-1, $tab_top+1); - $pdf->MultiCell($this->posxlabel-$this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C'); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); + $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C'); } //Label Product //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxlabel-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C'); + $pdf->SetXY($this->posxlabel - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C'); } //Lot/serie Product @@ -907,37 +907,37 @@ class pdf_stdmovement extends ModelePDFMovement //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C'); } //Label mouvement //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxunit, $tab_top+1); - $pdf->MultiCell($this->posxdiscount-$this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C'); + $pdf->SetXY($this->posxunit, $tab_top + 1); + $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C'); } //Origin //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxdiscount+2, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C'); + $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C'); } //Qty //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->postotalht+2, $tab_top+1); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->postotalht + 2, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } $pdf->SetDrawColor(220, 26, 26); - $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); - $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26))); + $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); $pdf->SetLineStyle(array('dash'=>0)); } @@ -954,20 +954,20 @@ class pdf_stdmovement extends ModelePDFMovement */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { - global $conf,$langs,$db,$hookmanager; + global $conf, $langs, $db, $hookmanager; // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks")); $default_font_size = pdf_getPDFFontSize($outputlangs); - if ($object->type == 1) $titlekey='ServiceSheet'; - else $titlekey='StockSheet'; + if ($object->type == 1) $titlekey = 'ServiceSheet'; + else $titlekey = 'StockSheet'; pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); } @@ -1048,25 +1048,25 @@ class pdf_stdmovement extends ModelePDFMovement // Description $nexY = $pdf->GetY(); - $nexY+=5; + $nexY += 5; $pdf->SetXY($posx, $posy); $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); $nexY = $pdf->GetY(); - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1); $nexY = $pdf->GetY(); // Nb of products - $valtoshow=price2num($calcproducts['nb'], 'MS'); - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $valtoshow = price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow) ? '0' : $valtoshow), 0, 1); $nexY = $pdf->GetY(); // Value - $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); $nexY = $pdf->GetY(); @@ -1078,7 +1078,7 @@ class pdf_stdmovement extends ModelePDFMovement if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -1128,7 +1128,7 @@ class pdf_stdmovement extends ModelePDFMovement } }*/ - $posy+=2; + $posy += 2; // Show list of linked objects //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); @@ -1184,7 +1184,7 @@ class pdf_stdmovement extends ModelePDFMovement protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 29652f09b88..0579c464d30 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -26,7 +26,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; @@ -41,8 +41,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - $params = isset($tpl_context) ? array('tpl_context' => $tpl_context) : array(); // BUG #11554 : Add tpl_context in params - print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params + $params = isset($tpl_context) ? array('tpl_context' => $tpl_context) : array(); // BUG #11554 : Add tpl_context in params + print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params } ?> diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 6a61686e5cc..32fff114739 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -26,22 +26,22 @@ */ // 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; } -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); ?> fk_soc)) $parameters['socid'] = $object->fk_soc; +if (!is_array($parameters)) $parameters = array(); +if (!empty($cols)) $parameters['colspan'] = ' colspan="'.$cols.'"'; +if (!empty($cols)) $parameters['cols'] = $cols; +if (!empty($object->fk_soc)) $parameters['socid'] = $object->fk_soc; $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -94,10 +94,10 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if (!empty($extrafield_param) && is_array($extrafield_param)) { $extrafield_param_list = array_keys($extrafield_param['options']); - if (count($extrafield_param_list)>0) { + if (count($extrafield_param_list) > 0) { $extrafield_collapse_display_value = intval($extrafield_param_list[0]); - if ($extrafield_collapse_display_value==1 || $extrafield_collapse_display_value==2) { + if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) { $extrafields_collapse_num = $extrafields->attributes[$object->table_element]['pos'][$key]; } } @@ -105,7 +105,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print $extrafields->showSeparator($key, $object); - $lastseparatorkeyfound=$key; + $lastseparatorkeyfound = $key; } else { @@ -184,14 +184,14 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } print ''; - print '' . "\n"; + print ''."\n"; } } // Add code to manage list depending on others // TODO Test/enhance this with a more generic solution - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print "\n"; print ' diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f58b6725f81..b2ab12041af 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -115,12 +115,12 @@ if ($nolinesbefore) { multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> trans('PriceUHTCurrency'); ?> - + trans('PriceUTTC'); ?> trans('Qty'); ?> global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { print ''; print ''; @@ -466,20 +466,20 @@ $coldisplay+=$colspan; showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); } -if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required +if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { ?> > - global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - + global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> + element) && $object->element == 'contrat') + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + if (!empty($object->element) && $object->element == 'contrat') { print $langs->trans("DateStartPlanned").' '; print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); @@ -489,9 +489,9 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da else { echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); + print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); echo ' '.$langs->trans('to').' '; - print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1, 1, "addproduct", 1, 0); + print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); }; print ''; // Loan card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref.='
        '.$langs->trans('Project') . ' '; + $morehtmlref .= '
        '.$langs->trans('Project').' '; if ($user->rights->loan->write) { 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', $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 .= '
        '; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -493,7 +493,7 @@ if ($id > 0) if ($action == 'edit') { print ''.$langs->trans("LoanCapital").''; - print ''; + print ''; print ''; } else @@ -505,7 +505,7 @@ if ($id > 0) if ($action == 'edit') { print ''.$langs->trans("Insurance").''; - print ''; + print ''; print ''; } else @@ -544,7 +544,7 @@ if ($id > 0) print ''; if ($action == 'edit') { - print ''; + print ''; } else { @@ -557,11 +557,11 @@ if ($id > 0) print ''; if ($action == 'edit') { - print '%'; + print '%'; } else { - print $object->rate . '%'; + print $object->rate.'%'; } print ''; @@ -573,7 +573,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1); } @@ -589,7 +589,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_capital, 1); @@ -611,7 +611,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInsuranceCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1); } @@ -627,7 +627,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_insurance, 1); @@ -649,7 +649,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1); } @@ -665,7 +665,7 @@ if ($id > 0) print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->account_interest, 1); @@ -689,15 +689,15 @@ if ($id > 0) * Payments */ $sql = "SELECT p.rowid, p.num_payment, datep as dp,"; - $sql.= " p.amount_capital, p.amount_insurance, p.amount_interest,"; - $sql.= " c.libelle as paiement_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql.= ", ".MAIN_DB_PREFIX."loan as l"; - $sql.= " WHERE p.fk_loan = ".$id; - $sql.= " AND p.fk_loan = l.rowid"; - $sql.= " AND l.entity IN ( ".getEntity('loan').")"; - $sql.= " ORDER BY dp DESC"; + $sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,"; + $sql .= " c.libelle as paiement_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ", ".MAIN_DB_PREFIX."loan as l"; + $sql .= " WHERE p.fk_loan = ".$id; + $sql .= " AND p.fk_loan = l.rowid"; + $sql .= " AND l.entity IN ( ".getEntity('loan').")"; + $sql .= " ORDER BY dp DESC"; //print $sql; $resql = $db->query($sql); @@ -709,7 +709,7 @@ if ($id > 0) $total_interest = 0; $total_capital = 0; - 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 print ''; print ''; print ''; @@ -746,7 +746,7 @@ if ($id > 0) $staytopay = $object->capital - $totalpaid; print ''; - print ''; } @@ -804,7 +804,7 @@ if ($id > 0) } // Classify 'paid' - if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) + if ($object->paid == 0 && round($staytopay) <= 0 && $user->rights->loan->write) { print ''; } diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index a4bed07949e..a4328bec863 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -53,21 +53,21 @@ if (empty($page) || $page == -1) { $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"; $object = new Loan($db); if ($id > 0) $object->fetch($id); $upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='loan'; +$modulepart = 'loan'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -76,45 +76,45 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Documents"); +$title = $langs->trans("Loan").' - '.$langs->trans("Documents"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); if ($object->id) { - $totalpaid=$object->getSumPayment(); + $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Loan"), -1, 'bill'); - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $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 .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -122,11 +122,11 @@ if ($object->id) } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -135,11 +135,11 @@ if ($object->id) // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $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']; } @@ -155,8 +155,8 @@ if ($object->id) $modulepart = 'loan'; $permission = $user->rights->loan->write; $permtoedit = $user->rights->loan->write; - $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'; } else { diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 618345518ed..1a26a8a12da 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -48,7 +48,7 @@ $result = restrictedArea($user, 'loan', $id, '', ''); $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Info"); +$title = $langs->trans("Loan").' - '.$langs->trans("Info"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); @@ -60,33 +60,33 @@ $head = loan_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("Loan"), -1, 'bill'); -$morehtmlref='
        '; +$morehtmlref = '
        '; // Ref loan -$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $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 .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -94,11 +94,11 @@ if (! empty($conf->projet->enabled)) { } } } -$morehtmlref.='
        '; +$morehtmlref .= '
        '; -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = ''.$langs->trans("BackToList").''; -$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 4ddd7bdccee..ebe0b9d876c 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -30,8 +30,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } $action = GETPOST('action', 'aZ09'); @@ -46,7 +46,7 @@ $result = restrictedArea($user, 'loan', $id, '&loan'); $object = new Loan($db); if ($id > 0) $object->fetch($id); -$permissionnote=$user->rights->loan->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php /* @@ -62,7 +62,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Notes"); +$title = $langs->trans("Loan").' - '.$langs->trans("Notes"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $title, $help_url); @@ -71,39 +71,39 @@ if ($id > 0) /* * Affichage onglets */ - $totalpaid=$object->getSumPayment(); + $totalpaid = $object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("Loan"), -1, 'bill'); - $morehtmlref='
        '; + $morehtmlref = '
        '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref .= '
        ' . $langs->trans('Project') . ' : '; + $morehtmlref .= '
        '.$langs->trans('Project').' : '; if ($user->rights->loan->write) { //if ($action != 'classify') // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
        '; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $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 .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } else { @@ -111,19 +111,19 @@ if ($id > 0) } } } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
        '; print '
        '; - $cssclass='titlefield'; - $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php + $cssclass = 'titlefield'; + $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index cdd8db1a0bd..302ecf5f1ff 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; if (!$user->rights->opensurvey->read) accessforbidden(); // Initialisation des variables -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $numsondage = ''; @@ -44,16 +44,16 @@ if (GETPOST('id')) { $numsondage = GETPOST('id', 'alpha'); } -$object=new Opensurveysondage($db); +$object = new Opensurveysondage($db); -$result=$object->fetch(0, $numsondage); +$result = $object->fetch(0, $numsondage); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); +$expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); @@ -67,7 +67,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action=''; + if ($cancel) $action = ''; // Delete if ($action == 'delete_confirm') @@ -75,7 +75,7 @@ if (empty($reshook)) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $result=$object->delete($user, '', $numsondage); + $result = $object->delete($user, '', $numsondage); header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); exit(); @@ -101,16 +101,16 @@ if (empty($reshook)) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $error=0; + $error = 0; - if (! GETPOST('nouveautitre')) + if (!GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - if (! $error) + if (!$error) { $object->titre = GETPOST('nouveautitre', 'nohtml'); $object->commentaires = GETPOST('nouveauxcommentaires', 'nohtml'); @@ -121,11 +121,11 @@ if (empty($reshook)) $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? true : false; $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; - $res=$object->update($user); + $res = $object->update($user); if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; + $action = 'edit'; } } } @@ -133,27 +133,27 @@ if (empty($reshook)) // Add comment if (GETPOST('ajoutcomment')) { - $error=0; + $error = 0; - if (! GETPOST('comment')) + if (!GETPOST('comment')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } - if (! GETPOST('commentuser')) + if (!GETPOST('commentuser')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } - if (! $error) + if (!$error) { $comment = GETPOST("comment"); $comment_user = GETPOST('commentuser'); $resql = $object->addComment($comment, $comment_user); - if (! $resql) + if (!$resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } @@ -161,7 +161,7 @@ if (empty($reshook)) } // Delete comment - $idcomment=GETPOST('deletecomment', 'int'); + $idcomment = GETPOST('deletecomment', 'int'); if ($idcomment) { // Security check @@ -181,7 +181,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); if ($object->fk_user_creat) { @@ -191,21 +191,21 @@ if ($object->fk_user_creat) $title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("@", "
        ", $toutsujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("@", "
        ", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print '
        '."\n"; print ''; @@ -228,15 +228,15 @@ print '
        '; print '
        '.$langs->trans("RefPayment").'
        '.$langs->trans("RemainderToPay").' :'; + print ''; print price($staytopay, 0, $langs, 0, 0, -1, $conf->currency); print '
        '; // Type -$type=($object->format=="A")?'classic':'date'; +$type = ($object->format == "A") ? 'classic' : 'date'; print ''; +print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); +print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").''; // Title print ''; // Description -print ''; // EMail //If linked user, then emails are going to be sent to users' email if (!$object->fk_user_creat) { - print ''; print ''; @@ -300,14 +300,14 @@ print ''; print ''; // Expire date print ''; // Author print ''; print ''; - print ''; + print ''; // Parent entrepot print ''; print ''; // Zip / Town print ''; print ''; // Country print ''; // Status @@ -310,7 +310,7 @@ if ($action == 'create') print ''; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; if ($conf->categorie->enabled) { // Categories @@ -324,16 +324,16 @@ if ($action == 'create') dol_fiche_end(); print '
        '; - print ''; + print ''; print '     '; - print ''; + print ''; print '
        '; print ''; } else { - $id=GETPOST("id", 'int'); + $id = GETPOST("id", 'int'); if ($id > 0 || $ref) { $object = new Entrepot($db); @@ -364,8 +364,8 @@ else // Call Hook formConfirm $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -399,18 +399,18 @@ else // Description print ''; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print '"; // Nb of products print '"; print '
        '.$langs->trans("Type").''; -print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); -print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'
        '; -$adresseadmin=$object->mail_admin; -print $langs->trans("Title") .''; +$adresseadmin = $object->mail_admin; +print $langs->trans("Title").''; if ($action == 'edit') { print ''; @@ -245,22 +245,22 @@ else print dol_htmlentities($object->titre); print '
        '.$langs->trans("Description") .''; +print '
        '.$langs->trans("Description").''; if ($action == 'edit') { - $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires), '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); + $doleditor = new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires), '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); } else { - print (dol_textishtml($object->commentaires)?$object->commentaires:dol_nl2br($object->commentaires, 1, true)); + print (dol_textishtml($object->commentaires) ? $object->commentaires : dol_nl2br($object->commentaires, 1, true)); } print '
        '.$langs->trans("EMail") .''; + print '
        '.$langs->trans("EMail").''; if ($action == 'edit') { print ''; @@ -273,7 +273,7 @@ if (!$object->fk_user_creat) { print '
        '.$langs->trans('ToReceiveEMailForEachVote').''; if ($action == 'edit') { - print 'mailsonde?'checked="checked"':'').'">'; + print 'mailsonde ? 'checked="checked"' : '').'">'; } else { print yn($object->mailsonde); @@ -291,7 +291,7 @@ print '
        '.$langs->trans('CanComment').''; if ($action == 'edit') { - print 'allow_comments?'checked="checked"':'').'">'; + print 'allow_comments ? 'checked="checked"' : '').'">'; } else print yn($object->allow_comments); print '
        '.$langs->trans('CanSeeOthersVote').''; if ($action == 'edit') { - print 'allow_spy?'checked="checked"':'').'">'; + print 'allow_spy ? 'checked="checked"' : '').'">'; } else print yn($object->allow_spy); print '
        '.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate?$expiredate:$object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else { print dol_print_date($object->date_fin, 'day'); @@ -317,7 +317,7 @@ print '
        '; -print $langs->trans("Author") .''; +print $langs->trans("Author").''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { @@ -329,11 +329,11 @@ print '
        '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; +$url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage; print ''; if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url); @@ -365,17 +365,17 @@ print '
        '; if ($action != 'edit' && $user->rights->opensurvey->write) { //Modify button - print ''.$langs->trans("Modify") . ''; + print ''.$langs->trans("Modify").''; if ($object->status == Opensurveysondage::STATUS_VALIDATED) { //Close button - print ''.$langs->trans("Close") . ''; + print ''.$langs->trans("Close").''; } if ($object->status == Opensurveysondage::STATUS_CLOSED) { //Opened button - print ''.$langs->trans("ReOpen") . ''; + print ''.$langs->trans("ReOpen").''; } //Delete button @@ -419,12 +419,12 @@ print '
        '; // Add comment if ($object->allow_comments) { - print $langs->trans("AddACommentForPoll") . '
        '; + print $langs->trans("AddACommentForPoll").'
        '; print '
        '."\n"; - print $langs->trans("Name") .':
        '."\n"; + print $langs->trans("Name").':
        '."\n"; print '
        '."\n"; - if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") { - print "" . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")) . ""; + if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide == "yes") { + print "".$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")).""; } } diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 017779b74f7..7bb775e790e 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -35,14 +35,14 @@ if (!$user->rights->opensurvey->read) accessforbidden(); // Init vars -$action=GETPOST('action', 'aZ09'); -$numsondage= GETPOST("id"); +$action = GETPOST('action', 'aZ09'); +$numsondage = GETPOST("id"); -$object=new Opensurveysondage($db); -$result=$object->fetch(0, $numsondage); +$object = new Opensurveysondage($db); +$result = $object->fetch(0, $numsondage); if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage); -$nblines=$object->fetch_lines(); +$nblines = $object->fetch_lines(); /* @@ -65,28 +65,28 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $erreur_prenom = false; $nouveauchoix = ''; - for ($i=0;$i<$nbcolonnes;$i++) + for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $nom=substr(GETPOST("nom", 'nohtml'), 0, 64); + $nom = substr(GETPOST("nom", 'nohtml'), 0, 64); // Check if vote already exists $sql = 'SELECT id_users, nom as name'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; - $sql.= ' ORDER BY id_users'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; + $sql .= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."'"; + $sql .= ' ORDER BY id_users'; $resql = $db->query($sql); $num_rows = $db->num_rows($resql); if ($num_rows > 0) @@ -97,9 +97,9 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)'; - $sql.= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } } } @@ -108,19 +108,19 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout $testmodifier = false; $testligneamodifier = false; $ligneamodifier = -1; -for ($i=0; $i<$nblines; $i++) +for ($i = 0; $i < $nblines; $i++) { if (isset($_POST['modifierligne'.$i])) { - $ligneamodifier=$i; - $testligneamodifier=true; + $ligneamodifier = $i; + $testligneamodifier = true; } //test pour voir si une ligne est a modifier if (isset($_POST['validermodifier'.$i])) { - $modifier=$i; - $testmodifier=true; + $modifier = $i; + $testmodifier = true; } } if ($testmodifier) @@ -134,24 +134,24 @@ if ($testmodifier) //var_dump($_POST["choix$i"]); if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { - $nouveauchoix.="1"; + $nouveauchoix .= "1"; } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { - $nouveauchoix.="2"; + $nouveauchoix .= "2"; } else { // sinon c'est 0 - $nouveauchoix.="0"; + $nouveauchoix .= "0"; } } - $idtomodify=$_POST["idtomodify".$modifier]; + $idtomodify = $_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " SET reponses = '".$db->escape($nouveauchoix)."'"; - $sql.= " WHERE id_users = '".$db->escape($idtomodify)."'"; + $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; + $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } // Add column (not for date) @@ -160,18 +160,18 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $nouveauxsujets=$object->sujet; + $nouveauxsujets = $object->sujet; //on rajoute la valeur a la fin de tous les sujets deja entrés - $nouveauxsujets.=','; - $nouveauxsujets.=str_replace(array(",","@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"])?'':'@'.$_POST["typecolonne"]); + $nouveauxsujets .= ','; + $nouveauxsujets .= str_replace(array(",", "@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"]) ? '' : '@'.$_POST["typecolonne"]); //mise a jour avec les nouveaux sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -223,10 +223,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau if ($nouvelledate < $datesbase[0]) { $cleinsertion = 0; - } elseif ($nouvelledate > $datesbase[$taillebase-1]) { + } elseif ($nouvelledate > $datesbase[$taillebase - 1]) { $cleinsertion = count($datesbase); } else { - $nbdatesbase=count($datesbase); + $nbdatesbase = count($datesbase); for ($i = 0; $i < $nbdatesbase; $i++) { $j = $i + 1; @@ -239,10 +239,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") array_splice($datesbase, $cleinsertion, 0, $nouvelledate); $cle = array_search($nouvelledate, $datesbase); $dateinsertion = ''; - $nbofdates=count($datesbase); + $nbofdates = count($datesbase); for ($i = 0; $i < $nbofdates; $i++) { - $dateinsertion.=","; - $dateinsertion.=$datesbase[$i]; + $dateinsertion .= ","; + $dateinsertion .= $datesbase[$i]; } $dateinsertion = substr("$dateinsertion", 1); @@ -251,10 +251,10 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) { $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($dateinsertion)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($dateinsertion)."'"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); else { header('Location: results.php?id='.$object->id_sondage); } @@ -264,7 +264,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") } else { - $erreur_ajout_date="yes"; + $erreur_ajout_date = "yes"; } } @@ -276,24 +276,24 @@ for ($i = 0; $i < $nblines; $i++) // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - $compteur=0; + $compteur = 0; // Loop on each answer $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - $num=$db->num_rows($resql); + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); - if ($compteur==$i) + if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= ' WHERE id_users = '.$db->escape($obj->id_users); + $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); $resql2 = $db->query($sql2); } @@ -323,7 +323,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) //si le sujet n'est pas celui qui a été effacé alors on concatene if ($i != $j) { - if (! empty($nouveauxsujets)) $nouveauxsujets .= ','; + if (!empty($nouveauxsujets)) $nouveauxsujets .= ','; $nouveauxsujets .= $toutsujet[$j]; } @@ -332,26 +332,26 @@ for ($i = 0; $i < $nbcolonnes; $i++) // Mise a jour des sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); // Clean current answer to remove deleted columns $compteur = 0; - $sql ="SELECT id_users, nom as name, id_sondage, reponses"; - $sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; + $sql = "SELECT id_users, nom as name, id_sondage, reponses"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; } - $num=$db->num_rows($resql); + $num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $newcar = ''; $ensemblereponses = $obj->reponses; @@ -359,7 +359,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) // parcours de toutes les réponses actuelles for ($j = 0; $j < $nbcolonnes; $j++) { - $car=substr($ensemblereponses, $j, 1); + $car = substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { $newcar .= $car; @@ -368,8 +368,8 @@ for ($i = 0; $i < $nbcolonnes; $i++) // mise a jour des reponses utilisateurs dans la base $sql2 = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2.= " SET reponses = '".$db->escape($newcar)."'"; - $sql2.= " WHERE id_users = '".$db->escape($obj->id_users)."'"; + $sql2 .= " SET reponses = '".$db->escape($newcar)."'"; + $sql2 .= " WHERE id_users = '".$db->escape($obj->id_users)."'"; //print $sql2; dol_syslog('sql='.$sql2); $resql2 = $db->query($sql2); @@ -387,14 +387,14 @@ for ($i = 0; $i < $nbcolonnes; $i++) * View */ -$form=new Form($db); +$form = new Form($db); if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } -$result=$object->fetch(0, $numsondage); +$result = $object->fetch(0, $numsondage); if ($result <= 0) { dol_print_error($db, $object->error); @@ -403,21 +403,21 @@ if ($result <= 0) $title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices -$toutsujet=explode(",", $object->sujet); -$listofanswers=array(); +$toutsujet = explode(",", $object->sujet); +$listofanswers = array(); foreach ($toutsujet as $value) { - $tmp=explode('@', $value); - $listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox')); + $tmp = explode('@', $value); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); } -$toutsujet=str_replace("@", "
        ", $toutsujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = str_replace("@", "
        ", $toutsujet); +$toutsujet = str_replace("°", "'", $toutsujet); print ''."\n"; @@ -439,15 +439,15 @@ print '
        '; print ''; // Type -$type=($object->format=="A")?'classic':'date'; +$type = ($object->format == "A") ? 'classic' : 'date'; print ''; +print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); +print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").''; // Title print ''; // Expire date print ''; // Author print ''; print '
        '.$langs->trans("Type").''; -print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); -print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'
        '; -$adresseadmin=$object->mail_admin; -print $langs->trans("Title") .''; +$adresseadmin = $object->mail_admin; +print $langs->trans("Title").''; if ($action == 'edit') { print ''; @@ -457,13 +457,13 @@ print '
        '.$langs->trans('ExpireDate').''; -if ($action == 'edit') print $form->selectDate($expiredate?$expiredate:$object->date_fin, 'expire', 0, 0, 0, '', 1, 0); +if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else print dol_print_date($object->date_fin, 'day'); print '
        '; -print $langs->trans("Author") .''; +print $langs->trans("Author").''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { @@ -475,12 +475,12 @@ print '
        '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); +$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current -$url=$urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; -$urllink=''; +$url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage; +$urllink = ''; print $urllink; if ($action != 'edit') { @@ -505,7 +505,7 @@ print ''."\n"; print ''; @@ -523,11 +523,11 @@ if (GETPOST('ajoutsujet')) print "

        "."\n"; // Add new column - if ($object->format=="A") + if ($object->format == "A") { - print $langs->trans("AddNewColumn") .':

        '; + print $langs->trans("AddNewColumn").':

        '; print $langs->trans("Title").'
        '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'

        '; print ''; print '     '; @@ -538,12 +538,12 @@ if (GETPOST('ajoutsujet')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother=new FormOther($db); + $formother = new FormOther($db); //ajout d'une date avec creneau horaire - print $langs->trans("AddADate") .':

        '."\n"; + print $langs->trans("AddADate").':

        '."\n"; print ''."\n"; @@ -554,7 +554,7 @@ if (GETPOST('ajoutsujet')) print $formother->select_year('', 'nouvelleannee', 1, 0, 5, 0, 1); - print '

        '. $langs->trans("AddStartHour") .':

        '."\n"; + print '

        '.$langs->trans("AddStartHour").':

        '."\n"; print ''."\n"; - print '

        '. $langs->trans("AddEndHour") .':

        '."\n"; + print '

        '.$langs->trans("AddEndHour").':

        '."\n"; print ''."\n"; //reformatage des données des sujets du sondage -$toutsujet=explode(",", $object->sujet); -$toutsujet=str_replace("°", "'", $toutsujet); +$toutsujet = explode(",", $object->sujet); +$toutsujet = str_replace("°", "'", $toutsujet); print ''."\n"; print ''."\n"; @@ -628,7 +628,7 @@ print ''."\n"; // Show choice titles -if ($object->format=="D") +if ($object->format == "D") { //affichage des sujets du sondage print ''."\n"; @@ -636,9 +636,9 @@ if ($object->format=="D") print ''."\n"; //affichage des années - $colspan=1; - $nbofsujet=count($toutsujet); - for ($i=0;$i<$nbofsujet;$i++) + $colspan = 1; + $nbofsujet = count($toutsujet); + for ($i = 0; $i < $nbofsujet; $i++) { $current = $toutsujet[$i]; @@ -646,24 +646,24 @@ if ($object->format=="D") $current = substr($toutsujet[$i], 0, strpos($toutsujet[$i], '@')); } - if (isset($toutsujet[$i+1]) && strpos($toutsujet[$i+1], '@') !== false) { - $next = substr($toutsujet[$i+1], 0, strpos($toutsujet[$i+1], '@')); - } elseif (isset($toutsujet[$i+1])) { - $next = $toutsujet[$i+1]; + if (isset($toutsujet[$i + 1]) && strpos($toutsujet[$i + 1], '@') !== false) { + $next = substr($toutsujet[$i + 1], 0, strpos($toutsujet[$i + 1], '@')); + } elseif (isset($toutsujet[$i + 1])) { + $next = $toutsujet[$i + 1]; } $currenty = 0; - if ($current) $currenty=strftime("%Y", $current); + if ($current) $currenty = strftime("%Y", $current); $next = 0; - if ($next) $nexty=strftime("%Y", $next); - if (isset($toutsujet[$i+1]) && ($currenty == $nexty)) + if ($next) $nexty = strftime("%Y", $next); + if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -680,20 +680,20 @@ if ($object->format=="D") //affichage des mois $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { - $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() + $cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime() - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } - if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){ + if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -710,17 +710,17 @@ if ($object->format=="D") $colspan = 1; for ($i = 0; $i < $nbofsujet; $i++) { $cur = intval($toutsujet[$i]); - if (isset($toutsujet[$i+1]) === false) { + if (isset($toutsujet[$i + 1]) === false) { $next = false; } else { - $next = intval($toutsujet[$i+1]); + $next = intval($toutsujet[$i + 1]); } if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next, "%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) { $colspan++; } else { print ''."\n"; - $colspan=1; + $colspan = 1; } } @@ -736,7 +736,7 @@ if ($object->format=="D") print ''."\n"; for ($i = 0; isset($toutsujet[$i]); $i++) { - $heures=explode('@', $toutsujet[$i]); + $heures = explode('@', $toutsujet[$i]); if (isset($heures[1])) { print ''."\n"; } else { @@ -760,7 +760,7 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { - $tmp=explode('@', $toutsujet[$i]); + $tmp = explode('@', $toutsujet[$i]); print ''."\n"; } @@ -773,20 +773,20 @@ else $sumfor = array(); $sumagainst = array(); $compteur = 0; -$sql ="SELECT id_users, nom as name, id_sondage, reponses"; -$sql.=" FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; -$sql.=" WHERE id_sondage = '".$db->escape($numsondage)."'"; +$sql = "SELECT id_users, nom as name, id_sondage, reponses"; +$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; +$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'"; dol_syslog('sql='.$sql); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; } -$num=$db->num_rows($resql); +$num = $db->num_rows($resql); while ($compteur < $num) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $ensemblereponses = $obj->reponses; @@ -800,40 +800,40 @@ while ($compteur < $num) print ''."\n"; // si la ligne n'est pas a changer, on affiche les données - if (! $testligneamodifier) + if (!$testligneamodifier) { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); //print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz'; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -848,20 +848,20 @@ while ($compteur < $num) { $car = substr($ensemblereponses, $i, 1); print ''."\n"; @@ -872,33 +872,33 @@ while ($compteur < $num) for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (((string) $car) == "1") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { if (((string) $car) == "1") print ''."\n"; elseif (((string) $car) == "0") print ''."\n"; else print ''."\n"; // Total - if (! isset($sumfor[$i])) $sumfor[$i] = 0; - if (! isset($sumagainst[$i])) $sumagainst[$i] = 0; + if (!isset($sumfor[$i])) $sumfor[$i] = 0; + if (!isset($sumagainst[$i])) $sumagainst[$i] = 0; if (((string) $car) == "1") $sumfor[$i]++; if (((string) $car) == "0") $sumagainst[$i]++; } @@ -913,7 +913,7 @@ while ($compteur < $num) } //demande de confirmation pour modification de ligne - for ($i=0; $i<$nblines; $i++) + for ($i = 0; $i < $nblines; $i++) { if (isset($_POST["modifierligne".$i])) { @@ -943,23 +943,23 @@ if (empty($testligneamodifier)) for ($i = 0; $i < $nbcolonnes; $i++) { print ''."\n"; @@ -971,10 +971,10 @@ if (empty($testligneamodifier)) } // Select value of best choice (for checkbox columns only) -$nbofcheckbox=0; -for ($i=0; $i < $nbcolonnes + 1; $i++) +$nbofcheckbox = 0; +for ($i = 0; $i < $nbcolonnes + 1; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) $nbofcheckbox++; if (isset($sumfor[$i])) { @@ -993,18 +993,18 @@ for ($i=0; $i < $nbcolonnes + 1; $i++) // Show line total print ''."\n"; print ''."\n"; -print ''."\n"; +print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - $showsumfor = isset($sumfor[$i])?$sumfor[$i]:''; - $showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:''; + $showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : ''; + $showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : ''; if (empty($showsumfor)) $showsumfor = 0; if (empty($showsumagainst)) $showsumagainst = 0; print ''."\n"; } print ''; @@ -1015,7 +1015,7 @@ if ($nbofcheckbox >= 2) print ''."\n"; print ''."\n"; for ($i = 0; $i < $nbcolonnes; $i++) { - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) { print ''."\n"; } else { @@ -1043,7 +1043,7 @@ print '
        '; if ($current) print strftime("%Y", $current); print ''.dol_print_date($cur, "%B").''.dol_print_date($cur, "%a %e").''.dol_htmlentities($heures[1]).''.dol_htmlentities($tmp[0]).''.dol_htmlentities($obj->name).'OKKO'.$langs->trans("Yes").''.$langs->trans("No").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice, $car); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice, $car); } print 'OKKO'.$langs->trans("For").''.$langs->trans("Against").' '.$langs->trans("For").''.$langs->trans("Against").' '; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''; } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes")); print $form->selectarray("choix".$i, $arraychoice); } - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') { - $arraychoice=array('2'=>' ','0'=>$langs->trans("Against"),'1'=>$langs->trans("For")); + $arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For")); print $form->selectarray("choix".$i, $arraychoice); } print '
        '. $langs->trans("Total") .''.$langs->trans("Total").''; - if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'], array('yesno','foragainst'))) print $showsumfor; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; - if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; + if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'
        '.$langs->trans("No").': '.$showsumagainst; + if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'
        '.$langs->trans("Against").': '.$showsumagainst; print '
        '."\n"; print ''."\n"; -$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set +$toutsujet = explode(",", $object->sujet); // With old versions, this field was not set $compteursujet = 0; $meilleursujet = ''; @@ -1051,21 +1051,21 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { - $meilleursujet.=", "; + $meilleursujet .= ", "; if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; //var_dump($toutsujet); if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); - $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext'). ($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '') . ' - ' . $toutsujetdate[1]; + $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1]; } else { - $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext'). ($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); + $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); } } else { - $tmps=explode('@', $toutsujet[$i]); + $tmps = explode('@', $toutsujet[$i]); $meilleursujet .= dol_htmlentities($tmps[0]); } @@ -1082,9 +1082,9 @@ if ($nbofcheckbox >= 2) print '

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


        '."\n"; } diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 22356994008..ab9ba921e16 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -40,7 +40,7 @@ function paypaladmin_prepare_head() $head[$h][2] = 'paypalaccount'; $h++; - $object=new stdClass(); + $object = new stdClass(); // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -68,12 +68,12 @@ function showPaypalPaymentUrl($type, $ref) $langs->load("paypal"); $langs->load("paybox"); - $servicename='PayPal'; - $out='

        '; - $out.=img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
        '; - $url=getPaypalPaymentUrl(0, $type, $ref); - $out.=''; - $out.=ajax_autoselect("paypalurl", 0); + $servicename = 'PayPal'; + $out = '

        '; + $out .= img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
        '; + $url = getPaypalPaymentUrl(0, $type, $ref); + $out .= ''; + $out .= ajax_autoselect("paypalurl", 0); return $out; } @@ -92,92 +92,92 @@ function getPaypalPaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag { global $conf; - $ref=str_replace(' ', '', $ref); + $ref = str_replace(' ', '', $ref); if ($type == 'free') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; - else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + else $out .= '&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); } } if ($type == 'order') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode?'':''); - if ($mode == 1) $out.='order_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'order_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'invoice') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode?'':''); - if ($mode == 1) $out.='invoice_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'invoice_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'contractline') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode?'':''); - if ($mode == 1) $out.='contractline_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'contractline_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } if ($type == 'membersubscription') { - $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode?'':''); - if ($mode == 1) $out.='member_ref'; - if ($mode == 0) $out.=urlencode($ref); - $out.=($mode?'':''); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + $out = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode ? '' : ''); + if ($mode == 1) $out .= 'member_ref'; + if ($mode == 0) $out .= urlencode($ref); + $out .= ($mode ? '' : ''); + if (!empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; else { - $out.='&securekey='.($mode?'':''); - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); - $out.=($mode?'':''); + $out .= '&securekey='.($mode ? '' : ''); + if ($mode == 1) $out .= "hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; + if ($mode == 0) $out .= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.$type.$ref, 2); + $out .= ($mode ? '' : ''); } } } // For multicompany - $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities return $out; } @@ -209,27 +209,27 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, //' //'------------------------------------------------- - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; // For payment with Paypal only if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') { - $solutionType='Mark'; - $landingPage='Login'; + $solutionType = 'Mark'; + $landingPage = 'Login'; } // For payment with Credit card or Paypal if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') { - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; } // For payment with Credit card if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') { - $solutionType='Sole'; - $landingPage='Billing'; + $solutionType = 'Sole'; + $landingPage = 'Billing'; } dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); @@ -255,12 +255,12 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, ); $ack = strtoupper($resArray["ACK"]); - if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { - $token=$resArray["TOKEN"]; + $token = $resArray["TOKEN"]; // Redirect to paypal.com here - $payPalURL = $API_Url . $token; + $payPalURL = $API_Url.$token; header("Location: ".$payPalURL); exit; } @@ -274,15 +274,15 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, if ($ErrorCode == 10729) { - $mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
        Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
        \n"; + $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
        Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
        \n"; } else { - $mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "
        \n"; - $mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
        \n"; - $mesg.= $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
        \n"; - $mesg.= $langs->trans('ErrorCode') . ": " . $ErrorCode."
        \n"; - $mesg.= $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
        \n"; + $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
        \n"; + $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
        \n"; + $mesg .= $langs->trans('ShortErrorMessage').": ".$ErrorShortMsg."
        \n"; + $mesg .= $langs->trans('ErrorCode').": ".$ErrorCode."
        \n"; + $mesg .= $langs->trans('ErrorSeverityCode').": ".$ErrorSeverityCode."
        \n"; } return $mesg; @@ -342,92 +342,92 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $nvpstr = ''; //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call - $nvpstr = $nvpstr . "&RETURNURL=" . urlencode($returnURL); - $nvpstr = $nvpstr . "&CANCELURL=" . urlencode($cancelURL); - if (! empty($conf->global->PAYPAL_ALLOW_NOTES)) + $nvpstr = $nvpstr."&RETURNURL=".urlencode($returnURL); + $nvpstr = $nvpstr."&CANCELURL=".urlencode($cancelURL); + if (!empty($conf->global->PAYPAL_ALLOW_NOTES)) { - $nvpstr = $nvpstr . "&ALLOWNOTE=0"; + $nvpstr = $nvpstr."&ALLOWNOTE=0"; } if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) { - $nvpstr = $nvpstr . "&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted + $nvpstr = $nvpstr."&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted } else { - $nvpstr = $nvpstr . "&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) + $nvpstr = $nvpstr."&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) } - $nvpstr = $nvpstr . "&SOLUTIONTYPE=" . urlencode($solutionType); - $nvpstr = $nvpstr . "&LANDINGPAGE=" . urlencode($landingPage); - if (! empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) + $nvpstr = $nvpstr."&SOLUTIONTYPE=".urlencode($solutionType); + $nvpstr = $nvpstr."&LANDINGPAGE=".urlencode($landingPage); + if (!empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) { - $nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number + $nvpstr = $nvpstr."&CUSTOMERSERVICENUMBER=".urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number } $paypalprefix = 'PAYMENTREQUEST_0_'; //$paypalprefix = ''; - if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale'; + if (!empty($paypalprefix) && $paymentType == 'Sole') $paymentType = 'Sale'; - $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // Total for all elements + $nvpstr = $nvpstr."&AMT=".urlencode($paymentAmount); // Total for all elements - $nvpstr = $nvpstr . "&".$paypalprefix."INVNUM=" . urlencode($tag); - $nvpstr = $nvpstr . "&".$paypalprefix."AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&".$paypalprefix."ITEMAMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&".$paypalprefix."PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION - $nvpstr = $nvpstr . "&".$paypalprefix."CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE + $nvpstr = $nvpstr."&".$paypalprefix."INVNUM=".urlencode($tag); + $nvpstr = $nvpstr."&".$paypalprefix."AMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."ITEMAMT=".urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr."&".$paypalprefix."PAYMENTACTION=".urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr."&".$paypalprefix."CURRENCYCODE=".urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); - $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); + $nvpstr = $nvpstr."&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET=" . urlencode($shipToStreet); // - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET2=" . urlencode($shipToStreet2); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCITY=" . urlencode($shipToCity); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTATE=" . urlencode($shipToState); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); - $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip); - $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum); - if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL - if (! empty($desc)) $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTONAME=".urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET=".urlencode($shipToStreet); // + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTREET2=".urlencode($shipToStreet2); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCITY=".urlencode($shipToCity); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOSTATE=".urlencode($shipToState); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOCOUNTRYCODE=".urlencode($shipToCountryCode); + $nvpstr = $nvpstr."&".$paypalprefix."SHIPTOZIP=".urlencode($shipToZip); + $nvpstr = $nvpstr."&".$paypalprefix."PHONENUM=".urlencode($phoneNum); + if (!empty($email)) $nvpstr = $nvpstr."&".$paypalprefix."EMAIL=".urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + if (!empty($desc)) $nvpstr = $nvpstr."&".$paypalprefix."DESC=".urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC - if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) + if (!empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $urllogo=$urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); - $nvpstr = $nvpstr . "&LOGOIMG=" . urlencode($urllogo); + $urllogo = $urlwithroot."/viewimage.php?modulepart=mycompany&file=".urlencode('logos/'.$mysoc->logo); + $nvpstr = $nvpstr."&LOGOIMG=".urlencode($urllogo); } - if (! empty($conf->global->PAYPAL_BRANDNAME)) + if (!empty($conf->global->PAYPAL_BRANDNAME)) { - $nvpstr = $nvpstr . "&BRANDNAME=" . urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME + $nvpstr = $nvpstr."&BRANDNAME=".urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME } - if (! empty($conf->global->PAYPAL_NOTETOBUYER)) + if (!empty($conf->global->PAYPAL_NOTETOBUYER)) { - $nvpstr = $nvpstr . "&NOTETOBUYER=" . urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER + $nvpstr = $nvpstr."&NOTETOBUYER=".urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER } $_SESSION["FinalPaymentAmt"] = $paymentAmount; $_SESSION["currencyCodeType"] = $currencyCodeType; - $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' - $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip + $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' + $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. //' If an error occured, show the resulting errors //'--------------------------------------------------------------------------------------------------------------- - $resArray=hash_call("SetExpressCheckout", $nvpstr); + $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); - $_SESSION['TOKEN']=$token; + $_SESSION['TOKEN'] = $token; } return $resArray; @@ -459,7 +459,7 @@ function getDetails($token) //' Build a second API request to PayPal, using the token as the //' ID to get the details on the payment authorization //'--------------------------------------------------------------------------- - $nvpstr="&TOKEN=" . $token; + $nvpstr = "&TOKEN=".$token; //'--------------------------------------------------------------------------- //' Make the API call and store the results in an array. @@ -467,9 +467,9 @@ function getDetails($token) //' an action to complete the payment. //' If failed, show the error //'--------------------------------------------------------------------------- - $resArray=hash_call("GetExpressCheckoutDetails", $nvpstr); + $resArray = hash_call("GetExpressCheckoutDetails", $nvpstr); $ack = strtoupper($resArray["ACK"]); - if($ack == "SUCCESS" || $ack=="SUCCESSWITHWARNING") + if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $_SESSION['payer_id'] = $resArray['PAYERID']; } @@ -502,18 +502,18 @@ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipad global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; $nvpstr = ''; - $nvpstr .= '&TOKEN=' . urlencode($token); - $nvpstr .= '&PAYERID=' . urlencode($payerID); - $nvpstr .= '&PAYMENTACTION=' . urlencode($paymentType); - $nvpstr .= '&AMT=' . urlencode($FinalPaymentAmt); - $nvpstr .= '&CURRENCYCODE=' . urlencode($currencyCodeType); - $nvpstr .= '&IPADDRESS=' . urlencode($ipaddress); - $nvpstr .= '&INVNUM=' . urlencode($tag); + $nvpstr .= '&TOKEN='.urlencode($token); + $nvpstr .= '&PAYERID='.urlencode($payerID); + $nvpstr .= '&PAYMENTACTION='.urlencode($paymentType); + $nvpstr .= '&AMT='.urlencode($FinalPaymentAmt); + $nvpstr .= '&CURRENCYCODE='.urlencode($currencyCodeType); + $nvpstr .= '&IPADDRESS='.urlencode($ipaddress); + $nvpstr .= '&INVNUM='.urlencode($tag); /* Make the call to PayPal to finalize payment If an error occured, show the resulting errors */ - $resArray=hash_call("DoExpressCheckoutPayment", $nvpstr); + $resArray = hash_call("DoExpressCheckoutPayment", $nvpstr); /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' @@ -591,8 +591,8 @@ function hash_call($methodName, $nvpStr) global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; // TODO problem with triggers - $API_version="98.0"; - if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' + $API_version = "98.0"; + if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox' { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; @@ -604,14 +604,14 @@ function hash_call($methodName, $nvpStr) } // Clean parameters - $PAYPAL_API_USER=""; - if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; - $PAYPAL_API_PASSWORD=""; - if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; - $PAYPAL_API_SIGNATURE=""; - if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; - $PAYPAL_API_SANDBOX=""; - if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; + $PAYPAL_API_USER = ""; + if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; + $PAYPAL_API_PASSWORD = ""; + if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD; + $PAYPAL_API_SIGNATURE = ""; + if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE; + $PAYPAL_API_SANDBOX = ""; + if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; // TODO END problem with triggers dol_syslog("Paypal API endpoint ".$API_Endpoint); @@ -626,14 +626,14 @@ function hash_call($methodName, $nvpStr) curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); // TLSv1 by default or change to TLSv1.2 in module configuration - curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION)?1:$conf->global->PAYPAL_SSLVERSION)); + curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->PAYPAL_SSLVERSION) ? 1 : $conf->global->PAYPAL_SSLVERSION)); //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_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); @@ -641,15 +641,15 @@ function hash_call($methodName, $nvpStr) //if USE_PROXY constant set to true in Constants.php, then only proxy will be enabled. if ($USE_PROXY) { - dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); + dol_syslog("Paypal API hash_call 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); } //NVPRequest for submitting to server - $nvpreq ="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($API_version) . "&PWD=" . urlencode($PAYPAL_API_PASSWORD) . "&USER=" . urlencode($PAYPAL_API_USER) . "&SIGNATURE=" . urlencode($PAYPAL_API_SIGNATURE) . $nvpStr; - $nvpreq.="&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); + $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($API_version)."&PWD=".urlencode($PAYPAL_API_PASSWORD)."&USER=".urlencode($PAYPAL_API_USER)."&SIGNATURE=".urlencode($PAYPAL_API_SIGNATURE).$nvpStr; + $nvpreq .= "&LOCALECODE=".strtoupper($langs->getDefaultLang(1)); //$nvpreq.="&BRANDNAME=".urlencode(); // Override merchant name //$nvpreq.="&NOTIFYURL=".urlencode(); // For Instant Payment Notification url @@ -662,18 +662,18 @@ function hash_call($methodName, $nvpStr) //getting response from server $response = curl_exec($ch); - $nvpReqArray=deformatNVP($nvpreq); - $_SESSION['nvpReqArray']=$nvpReqArray; + $nvpReqArray = deformatNVP($nvpreq); + $_SESSION['nvpReqArray'] = $nvpReqArray; //convrting NVPResponse to an Associative Array dol_syslog("Paypal API hash_call Response nvpresp=".$response); - $nvpResArray=deformatNVP($response); + $nvpResArray = deformatNVP($response); if (curl_errno($ch)) { // moving to display page to display curl errors - $_SESSION['curl_error_no']=curl_errno($ch); - $_SESSION['curl_error_msg']=curl_error($ch); + $_SESSION['curl_error_no'] = curl_errno($ch); + $_SESSION['curl_error_msg'] = curl_error($ch); //Execute the Error handling module to display errors. } @@ -696,22 +696,22 @@ function hash_call($methodName, $nvpStr) */ function deformatNVP($nvpstr) { - $intial=0; + $intial = 0; $nvpArray = array(); - while(strlen($nvpstr)) + while (strlen($nvpstr)) { //postion of Key - $keypos= strpos($nvpstr, '='); + $keypos = strpos($nvpstr, '='); //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&'): strlen($nvpstr); + $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); /*getting the Key and Value values and storing in a Associative Array*/ - $keyval=substr($nvpstr, $intial, $keypos); - $valval=substr($nvpstr, $keypos+1, $valuepos-$keypos-1); + $keyval = substr($nvpstr, $intial, $keypos); + $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); //decoding the respose - $nvpArray[urldecode($keyval)] =urldecode($valval); - $nvpstr=substr($nvpstr, $valuepos+1, strlen($nvpstr)); + $nvpArray[urldecode($keyval)] = urldecode($valval); + $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); } return $nvpArray; } @@ -723,16 +723,16 @@ function deformatNVP($nvpstr) */ function getApiError() { - $errors=array(); + $errors = array(); - $resArray=$_SESSION['reshash']; + $resArray = $_SESSION['reshash']; - if(isset($_SESSION['curl_error_no'])) + if (isset($_SESSION['curl_error_no'])) { $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; } - foreach($resArray as $key => $value) + foreach ($resArray as $key => $value) { $errors[] = $key.'-'.$value; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 51deaf8c73b..f9a4a12b0df 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -673,18 +673,18 @@ class Products extends DolibarrApi throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } - $id = (empty($id)?0:$id); + $id = (empty($id) ? 0 : $id); - if(! DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); - if(! $result ) { + if (!$result) { throw new RestException(404, 'Product not found'); } - if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -765,18 +765,18 @@ class Products extends DolibarrApi throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } - $id = (empty($id)?0:$id); + $id = (empty($id) ? 0 : $id); - if(! DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); - if(! $result ) { + if (!$result) { throw new RestException(404, 'Product not found'); } - if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 72fd475e6ae..3c05b4e1ad1 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -37,11 +37,11 @@ class FormProduct /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; // Cache arrays - public $cache_warehouses=array(); - public $cache_lot=array(); + public $cache_warehouses = array(); + public $cache_lot = array(); /** @@ -76,7 +76,7 @@ class FormProduct { global $conf, $langs; - if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product + if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product if (is_array($exclude)) $excludeGroups = implode("','", $exclude); @@ -100,59 +100,59 @@ class FormProduct { if (!empty($batch)) { - $sql.= ", pb.qty as stock"; + $sql .= ", pb.qty as stock"; } else { - $sql.= ", ps.reel as stock"; + $sql .= ", ps.reel as stock"; } } elseif ($sumStock) { - $sql.= ", sum(ps.reel) as stock"; + $sql .= ", sum(ps.reel) as stock"; } - $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; if (!empty($fk_product)) { - $sql.= " AND ps.fk_product = '".$fk_product."'"; + $sql .= " AND ps.fk_product = '".$fk_product."'"; if (!empty($batch)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; } } - $sql.= " WHERE e.entity IN (".getEntity('stock').")"; + $sql .= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql.= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; + $sql .= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; } else { - $sql.= " AND e.statut = 1"; + $sql .= " AND e.statut = 1"; } - if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; + if (!empty($exclude)) $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; // minimum stock if ($stockMin !== false) { if (!empty($fk_product)) { if (!empty($batch)) { - $sql .= " AND pb.qty > " . $this->db->escape($stockMin); + $sql .= " AND pb.qty > ".$this->db->escape($stockMin); } else { - $sql .= " AND ps.reel > " . $this->db->escape($stockMin); + $sql .= " AND ps.reel > ".$this->db->escape($stockMin); } } } if ($sumStock && empty($fk_product)) { - $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; + $sql .= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; // minimum stock if ($stockMin !== false) { - $sql .= " HAVING sum(ps.reel) > " . $this->db->escape($stockMin); + $sql .= " HAVING sum(ps.reel) > ".$this->db->escape($stockMin); } } - $sql.= " ORDER BY " . $orderBy; + $sql .= " ORDER BY ".$orderBy; dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); $resql = $this->db->query($sql); @@ -164,16 +164,16 @@ class FormProduct { $obj = $this->db->fetch_object($resql); if ($sumStock) $obj->stock = price2num($obj->stock, 5); - $this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid; - $this->cache_warehouses[$obj->rowid]['label']=$obj->label; - $this->cache_warehouses[$obj->rowid]['parent_id']=$obj->fk_parent; + $this->cache_warehouses[$obj->rowid]['id'] = $obj->rowid; + $this->cache_warehouses[$obj->rowid]['label'] = $obj->label; + $this->cache_warehouses[$obj->rowid]['parent_id'] = $obj->fk_parent; $this->cache_warehouses[$obj->rowid]['description'] = $obj->description; $this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock; $i++; } // Full label init - foreach($this->cache_warehouses as $obj_rowid=>$tab) { + foreach ($this->cache_warehouses as $obj_rowid=>$tab) { $this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab); } @@ -197,11 +197,11 @@ class FormProduct private function get_parent_path($tab, $final_label = '') { //phpcs:enable - if(empty($final_label)) $final_label = $tab['label']; + if (empty($final_label)) $final_label = $tab['label']; - if(empty($tab['parent_id'])) return $final_label; + if (empty($tab['parent_id'])) return $final_label; else { - if(!empty($this->cache_warehouses[$tab['parent_id']])) { + if (!empty($this->cache_warehouses[$tab['parent_id']])) { $final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label; return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); } @@ -309,8 +309,8 @@ class FormProduct print '
        '; } else { if ($selected) { - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; - $warehousestatic=new Entrepot($this->db); + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + $warehousestatic = new Entrepot($this->db); $warehousestatic->fetch($selected); print $warehousestatic->getNomUrl(); } else { @@ -357,7 +357,7 @@ class FormProduct $return = ''; // TODO Use a cache - require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); $filter = array(); @@ -392,7 +392,7 @@ class FormProduct elseif ($mode == 2 && $lines->scale == $default) $return .= ' selected'; elseif ($mode == 0 && $lines->id == $default) $return .= ' selected'; $return .= '>'; - if ($measuring_style == 'time') $return.= $langs->trans(ucfirst($lines->label)); + if ($measuring_style == 'time') $return .= $langs->trans(ucfirst($lines->label)); else $return .= $langs->trans($lines->label); $return .= ''; } @@ -426,11 +426,11 @@ class FormProduct dol_syslog(get_class($this)."::selectLot $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $fk_entrepot, $empty_label, $forcecombo, $morecss", LOG_DEBUG); - $out=''; + $out = ''; $productIdArray = array(); - if (! is_array($objectLines) || ! count($objectLines)) + if (!is_array($objectLines) || !count($objectLines)) { - if (! empty($fk_product)) $productIdArray[] = $fk_product; + if (!empty($fk_product)) $productIdArray[] = $fk_product; } else { @@ -515,7 +515,7 @@ class FormProduct // check cache already loaded for product id's foreach ($productIdArray as $productId) { - $cacheLoaded = ! empty($this->cache_lot[$productId]) ? true : false; + $cacheLoaded = !empty($this->cache_lot[$productId]) ? true : false; } } if ($cacheLoaded) @@ -528,14 +528,14 @@ class FormProduct $this->cache_lot = array(); $productIdList = implode(',', $productIdArray); $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; if (!empty($productIdList)) { - $sql.= " WHERE ps.fk_product IN (".$productIdList.")"; + $sql .= " WHERE ps.fk_product IN (".$productIdList.")"; } - $sql.= " ORDER BY e.ref, pb.batch"; + $sql .= " ORDER BY e.ref, pb.batch"; dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG); $resql = $this->db->query($sql); @@ -546,10 +546,10 @@ class FormProduct while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->cache_lot[$obj->fk_product][$obj->rowid]['id'] =$obj->rowid; - $this->cache_lot[$obj->fk_product][$obj->rowid]['batch']=$obj->batch; - $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id']=$obj->fk_entrepot; - $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label']=$obj->label; + $this->cache_lot[$obj->fk_product][$obj->rowid]['id'] = $obj->rowid; + $this->cache_lot[$obj->fk_product][$obj->rowid]['batch'] = $obj->batch; + $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id'] = $obj->fk_entrepot; + $this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label'] = $obj->label; $this->cache_lot[$obj->fk_product][$obj->rowid]['qty'] = $obj->qty; $i++; } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 2659d325676..43821b99b31 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -27,15 +27,15 @@ include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) @@ -48,28 +48,28 @@ else } // Initialize technical objects -$object=new Inventory($db); +$object = new Inventory($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } -if (empty($action) && empty($id) && empty($ref)) $action='view'; +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); @@ -92,13 +92,13 @@ else * 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)) { - $error=0; + $error = 0; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; @@ -125,7 +125,7 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans('Inventory'), ''); @@ -160,10 +160,10 @@ if ($action == 'create') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
        '."\n"; @@ -172,7 +172,7 @@ if ($action == 'create') print '
        '; print ''; print '  '; - print ''; // Cancel for create does not post form if we don't know the backtopage + print ''; // Cancel for create does not post form if we don't know the backtopage print '
        '; print ''; @@ -196,10 +196,10 @@ if (($id || $ref) && $action == 'edit') print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; print '
        '; @@ -224,7 +224,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') @@ -236,14 +236,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -251,9 +251,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1); @@ -293,7 +293,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } */ - $morehtmlref.='
        '; + $morehtmlref .= '
        '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -305,10 +305,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '; print '
        '; @@ -322,14 +322,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { print '
        '."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Send - print '' . $langs->trans('SendMail') . ''."\n"; + print ''.$langs->trans('SendMail').''."\n"; if ($permissiontoadd) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 41e91b04d0c..6f8c5648275 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -33,28 +33,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'companies', 'categories')); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "DESC"; -$backtopage=GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check //$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('warehousecard', 'globalcard')); @@ -66,7 +66,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); // if ($ret > 0) // $ret = $object->fetch_thirdparty(); @@ -87,8 +87,8 @@ $usercanread = (($user->rights->stock->lire)); $usercancreate = (($user->rights->stock->creer)); $usercandelete = (($user->rights->stock->supprimer)); -$parameters=array('id'=>$id, 'ref'=>$ref); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id, 'ref'=>$ref); +$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)) { @@ -106,7 +106,7 @@ if (empty($reshook)) $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); - if (! empty($object->libelle)) + if (!empty($object->libelle)) { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -115,7 +115,7 @@ if (empty($reshook)) $action = 'create'; } - if (! $error) { + if (!$error) { $id = $object->create($user); if ($id > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -123,10 +123,10 @@ if (empty($reshook)) $categories = GETPOST('categories', 'array'); $object->setCategories($categories); if (!empty($backtopage)) { - header("Location: " . $backtopage); + header("Location: ".$backtopage); exit; } else { - header("Location: card.php?id=" . $id); + header("Location: card.php?id=".$id); exit; } } else { @@ -138,7 +138,7 @@ if (empty($reshook)) else { setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors'); - $action="create"; // Force retour sur page creation + $action = "create"; // Force retour sur page creation } } @@ -146,7 +146,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) { $object->fetch(GETPOST('id', 'int')); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -156,7 +156,7 @@ if (empty($reshook)) else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -179,7 +179,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) { + if (!$error) { $ret = $object->update($id, $user); if ($ret < 0) $error++; } @@ -205,7 +205,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) { + if (!$error) { $result = $object->insertExtraFields(); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -232,13 +232,13 @@ if (empty($reshook)) * View */ -$productstatic=new Product($db); -$form=new Form($db); -$formproduct=new FormProduct($db); -$formcompany=new FormCompany($db); +$productstatic = new Product($db); +$form = new Form($db); +$formproduct = new FormProduct($db); +$formcompany = new FormCompany($db); $formfile = new FormFile($db); -$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); @@ -260,7 +260,7 @@ if ($action == 'create') // Ref print '
        '.$langs->trans("Ref").'
        '.$langs->trans("LocationSummary").'
        '.$langs->trans("LocationSummary").'
        '.$langs->trans("AddIn").''; @@ -271,25 +271,25 @@ if ($action == 'create') print '
        '.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc', (!empty($object->description)?$object->description:''), '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print '
        '.$langs->trans('Address').'
        '.$langs->trans('Zip').''; - print $formcompany->select_ziptown((!empty($object->zip)?$object->zip:''), 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown((!empty($object->zip) ? $object->zip : ''), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print '
        '.$langs->trans('Town').''; - print $formcompany->select_ziptown((!empty($object->town)?$object->town:''), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((!empty($object->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); print '
        '.$langs->trans("Description").''.nl2br($object->description).'
        '.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print "
        '.$langs->trans("NumberOfProducts").''; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print "
        '; @@ -424,7 +424,7 @@ else // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -450,9 +450,9 @@ else } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; print $form->showCategories($object->id, 'warehouse', 1); print ""; @@ -476,8 +476,8 @@ else print "
        \n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if (empty($action)) @@ -525,16 +525,16 @@ else } print "\n"; - $totalunit=0; - $totalvalue=$totalvaluesell=0; + $totalunit = 0; + $totalvalue = $totalvaluesell = 0; $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; - $sql.= " ps.reel as value"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE ps.fk_product = p.rowid"; - $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) - $sql.= " AND ps.fk_entrepot = ".$object->id; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " ps.reel as value"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE ps.fk_product = p.rowid"; + $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) + $sql .= " AND ps.fk_entrepot = ".$object->id; + $sql .= $db->order($sortfield, $sortorder); dol_syslog('List products', LOG_DEBUG); $resql = $db->query($sql); @@ -547,13 +547,13 @@ else $objp = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) @@ -567,12 +567,12 @@ else //print ''.dol_print_date($objp->datem).''; print ''; print ""; - $productstatic->id=$objp->rowid; + $productstatic->id = $objp->rowid; $productstatic->ref = $objp->ref; $productstatic->label = $objp->produit; - $productstatic->type=$objp->type; - $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; print $productstatic->getNomUrl(1, 'stock', 16); print ''; @@ -580,31 +580,31 @@ else print ''.$objp->produit.''; print ''; - $valtoshow=price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function + print empty($valtoshow) ? '0' : $valtoshow; print ''; - $totalunit+=$objp->value; + $totalunit += $objp->value; // Price buy PMP print ''.price(price2num($objp->ppmp, 'MU')).''; // Total PMP - print ''.price(price2num($objp->ppmp*$objp->value, 'MT')).''; - $totalvalue+=price2num($objp->ppmp*$objp->value, 'MT'); + print ''.price(price2num($objp->ppmp * $objp->value, 'MT')).''; + $totalvalue += price2num($objp->ppmp * $objp->value, 'MT'); // Price sell min if (empty($conf->global->PRODUIT_MULTIPRICES)) { - $pricemin=$objp->price; + $pricemin = $objp->price; print ''; print price(price2num($pricemin, 'MU'), 1); print ''; // Total sell min print ''; - print price(price2num($pricemin*$objp->value, 'MT'), 1); + print price(price2num($pricemin * $objp->value, 'MT'), 1); print ''; } - $totalvaluesell+=price2num($pricemin*$objp->value, 'MT'); + $totalvaluesell += price2num($pricemin * $objp->value, 'MT'); if ($user->rights->stock->mouvement->creer) { @@ -627,8 +627,8 @@ else print ''.$langs->trans("Total").''; print ''; - $valtoshow=price2num($totalunit, 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($totalunit, 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print ''; print ' '; print ''.price(price2num($totalvalue, 'MT')).''; @@ -681,7 +681,7 @@ else print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); print ''; @@ -691,15 +691,15 @@ else // Zip / Town print ''.$langs->trans('Zip').''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town','selectcountry_id','state_id'), 6); + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ''; print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print ''; // Country print ''.$langs->trans('Country').''; - print $form->select_country($object->country_id?$object->country_id:$mysoc->country_code, 'country_id'); + print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; @@ -721,8 +721,8 @@ else print ''; // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -735,8 +735,8 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_WAREHOUSE, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_WAREHOUSE); - $arrayselected=array(); - foreach($cats as $cat) { + $arrayselected = array(); + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -763,7 +763,7 @@ else if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $modulepart='stock'; + $modulepart = 'stock'; if ($action != 'create' && $action != 'edit' && $action != 'delete') { @@ -773,28 +773,28 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Documents $objectref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/' . $objectref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/'.$objectref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; $modulepart = 'stock'; print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '
        '; $MAXEVENT = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, 'stock', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print '
        '; } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 60c98d81a60..09273ee947d 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -37,29 +37,29 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.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('products', 'stocks', 'orders')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$msid=GETPOST('msid', 'int'); -$product_id=GETPOST("product_id", 'int'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id", 'int'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; // Security check //$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); @@ -73,18 +73,18 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); +$search_type_mouvement = GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortfield) $sortfield="m.datem"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; -$pdluoid=GETPOST('pdluoid', 'int'); +$pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -95,17 +95,17 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$arrayfields=array( +$arrayfields = array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), @@ -132,11 +132,11 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -144,45 +144,45 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year=''; - $month=''; - $search_ref=''; - $search_movement=""; - $search_type_mouvement=""; - $search_inventorycode=""; - $search_product_ref=""; - $search_product=""; - $search_warehouse=""; - $search_user=""; - $search_batch=""; - $search_qty=''; - $sall=""; - $toselect=''; - $search_array_options=array(); + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); } // Correct stock if ($action == "correct_stock") { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - $error=0; + $error = 0; if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! is_numeric($_POST["nbpiece"])) + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! $error) + if (!$error) { $origin_element = ''; $origin_id = null; @@ -227,7 +227,7 @@ if ($action == "correct_stock") GETPOST('inventorycode'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -239,72 +239,72 @@ if ($action == "correct_stock") { $error++; setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } - if (! $error) $action=''; + if (!$error) $action = ''; } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); - $result=$product->fetch($product_id); + $result = $product->fetch($product_id); - if ($product->hasbatch() && ! GETPOST("batch_number")) + if ($product->hasbatch() && !GETPOST("batch_number")) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Entrepot($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; if ($product->hasbatch()) { @@ -312,13 +312,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -328,16 +328,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=$id; - $batch=GETPOST('batch_number'); - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = $id; + $batch = GETPOST('batch_number'); + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -348,7 +348,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -363,7 +363,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id, GETPOST("nbpiece"), @@ -374,7 +374,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -384,7 +384,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -403,7 +403,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($product->error, $product->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -484,9 +484,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -if(empty($search_inventorycode)) +if (empty($search_inventorycode)) { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } else { @@ -497,7 +497,7 @@ else $resql = $db->query($sql); -if(!empty($search_inventorycode)) $limit = $db->num_rows($resql); +if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); if ($resql) { @@ -519,16 +519,16 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } llxHeader("", $texte, $help_url); @@ -565,18 +565,18 @@ if ($resql) // Description print ''.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).''; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print ''.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print ""; // Nb of products print ''.$langs->trans("NumberOfProducts").''; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print ""; print ''; @@ -590,7 +590,7 @@ if ($resql) // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -601,7 +601,7 @@ if ($resql) if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -673,32 +673,32 @@ if ($resql) print '

        '; } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($id > 0) $param.='&id='.$id; - if ($search_movement) $param.='&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param.='&search_product='.urlencode($search_product); - if ($search_batch) $param.='&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param.='&search_warehouse='.urlencode($search_warehouse); - if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined - if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined - if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($idproduct > 0) $param.='&idproduct='.$idproduct; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($id > 0) $param .= '&id='.$id; + if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined + if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.$idproduct; // 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"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
        '; if ($optioncss != '') print ''; @@ -717,147 +717,147 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
        '.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
        '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
        '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
        '; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; print '
        '; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
        '; - print ''."\n"; + print '
        '."\n"; // Fields title search print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print ''; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print ''; } // Batch - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print ''; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print ''; } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } - if (! empty($arrayfields['m.fk_projet']['checked'])) + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print ''; } // Date modification - if (! empty($arrayfields['m.tms']['checked'])) + if (!empty($arrayfields['m.tms']['checked'])) { print ''; } // Actions print ''; print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) { + if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['m.datem']['checked'])) { + if (!empty($arrayfields['m.datem']['checked'])) { print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['m.batch']['checked'])) { + if (!empty($arrayfields['m.batch']['checked'])) { print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['pl.eatby']['checked'])) { + if (!empty($arrayfields['pl.eatby']['checked'])) { print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['pl.sellby']['checked'])) { + if (!empty($arrayfields['pl.sellby']['checked'])) { print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.fk_user_author']['checked'])) { + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.inventorycode']['checked'])) { + if (!empty($arrayfields['m.inventorycode']['checked'])) { print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.label']['checked'])) { + if (!empty($arrayfields['m.label']['checked'])) { print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.type_mouvement']['checked'])) { + if (!empty($arrayfields['m.type_mouvement']['checked'])) { print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['origin']['checked'])) { + if (!empty($arrayfields['origin']['checked'])) { print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.value']['checked'])) { + if (!empty($arrayfields['m.value']['checked'])) { print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['m.price']['checked'])) { + if (!empty($arrayfields['m.price']['checked'])) { print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['m.fk_projet']['checked'])) { + if (!empty($arrayfields['m.fk_projet']['checked'])) { print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, 'align="right"', $sortfield, $sortorder); } @@ -1001,23 +1001,23 @@ if ($resql) print ''; // Id movement - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { - print ''; // This is primary not movement id + print ''; // This is primary not movement id } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { // Date print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '\n"; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '\n"; } - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '\n"; } // Author - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '\n"; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement){ + switch ($objp->type_mouvement) { case "0": print ''; break; @@ -1093,12 +1093,12 @@ if ($resql) break; } } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } - if (! empty($arrayfields['m.fk_projet']['checked'])) + if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; @@ -1145,16 +1145,16 @@ if ($resql) { print "
        "; - $productidselected=0; + $productidselected = 0; foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected=$key; - $productlabelselected=$val; + $productidselected = $key; + $productlabelselected = $val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); - $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); + $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print '
        '; print ''; print ''; print ''; if (empty($conf->productbatch->enabled)) print ' '; //else print '
        '; - $syear = $year?$year:-1; + $syear = $year ? $year : -1; print ''; //print $formother->selectyear($syear,'year',1, 20, 5); print '
        '; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; //print ''; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; //print ''; print ''; print ajax_combobox('search_type_mouvement'); // TODO: add new function $formentrepot->selectTypeOfMovement(...) like // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print '  '; print ''; print ''; print ''; print '  '; print ''; @@ -870,76 +870,76 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['m.datec']['checked'])) + if (!empty($arrayfields['m.datec']['checked'])) { print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$objp->mid.''.$objp->mid.''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; print $productstatic->getNomUrl(1, 'stock', 16); print "'; @@ -1028,36 +1028,36 @@ if ($resql) print $productstatic->label; print "'; if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. print ''. dol_print_date($objp->eatby, 'day') .''.dol_print_date($objp->eatby, 'day').''. dol_print_date($objp->sellby, 'day') .''.dol_print_date($objp->sellby, 'day').''; print $warehousestatic->getNomUrl(1); print "'; print $userstatic->getNomUrl(-1); print "'.''.$objp->label.''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$origin.''; @@ -1106,14 +1106,14 @@ if ($resql) print $objp->qty; print ''; if ($objp->price != 0) print price($objp->price); print ''; @@ -1124,12 +1124,12 @@ if ($resql) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
        '; print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 77dcaa641d2..fffab036d2d 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -115,9 +115,9 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Definition of fields for list -$arrayfields=array(); -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields = array(); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -130,17 +130,17 @@ $arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'ena // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); -$search_array_options_project=$extrafields->getOptionalsFromPost($project->table_element, '', 'search_'); -$search_array_options_task=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_task_'); +$search_array_options_project = $extrafields->getOptionalsFromPost($project->table_element, '', 'search_'); +$search_array_options_task = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_task_'); /* @@ -151,7 +151,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost($object->table_ele 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -163,7 +163,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -196,35 +196,35 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -250,22 +250,22 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timespent_duration=array(); + $timespent_duration = array(); if (is_array($_POST)) { - foreach($_POST as $key => $time) + foreach ($_POST as $key => $time) { if (intval($time) > 0) { @@ -276,10 +276,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($id > 0) { // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + if ($matches[2] == 'hour') $timespent_duration[$id] += $time * 60 * 60; // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration[$id] += $time*60; + if ($matches[2] == 'min') $timespent_duration[$id] += $time * 60; } } } @@ -288,11 +288,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if (count($timespent_duration) > 0) { - foreach($timespent_duration as $key => $val) + foreach ($timespent_duration as $key => $val) { $object->fetch($key); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $val; @@ -311,7 +311,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac if ($object->timespent_date > 0) { - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); } else { @@ -328,12 +328,12 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid ? 'id='.$projectid : '').($search_usertoprocessid ? '&search_usertoprocessid='.$search_usertoprocessid : '').($mode ? '&mode='.$mode : '').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); exit; } } @@ -349,11 +349,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); +$form = new Form($db); $formother = new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); @@ -369,9 +369,9 @@ $next_year = $next['year']; $next_month = $next['mon']; $next_day = $next['mday']; -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -379,14 +379,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -397,18 +397,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($usertoprocess); //var_dump($projectsrole); //var_dump($taskrole); @@ -417,33 +417,33 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print 'id > 0 ? '?id='.$project->id : '').'">'; print ''; @@ -456,18 +456,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperday', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -482,13 +482,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -498,7 +498,7 @@ print '
        '; print '
        '; -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /*if (! empty($conf->categorie->enabled)) @@ -511,66 +511,66 @@ $moreforfilter=''; }*/ // If the user can view user other than himself -$moreforfilter.='
        '; -$moreforfilter.='
        '.$langs->trans('User'). '
        '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); -$moreforfilter.='
        '; +$moreforfilter .= '
        '; +$moreforfilter .= '
        '.$langs->trans('User').'
        '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); +$moreforfilter .= '
        '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('Project'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('Project').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('ThirdParty'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('ThirdParty').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // This must be after the $selectedfields -$addcolspan=0; -if (! empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (! empty($arrayfields['t.progress']['checked'])) $addcolspan++; +$addcolspan = 0; +if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; +if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; foreach ($arrayfields as $key => $val) { if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; } print '
        '; -print ''."\n"; +print '
        '."\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print ''; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -580,24 +580,24 @@ print ''; print ''; // Action column print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -605,17 +605,17 @@ if (! empty($arrayfields['t.progress']['checked'])) if ($usertoprocess->id == $user->id) print ''; else print '';*/ print ''; -print ''; +print ''; print ''; +print ''; print ''; //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$colspan=4+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); +$colspan = 4 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; - print ''; print ''; - $tmparray = dol_getdate($daytoparse, true); // detail of current day + $tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $cssonholiday=''; - if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; print ''; print ''; @@ -690,32 +690,32 @@ if (count($tasksarray) > 0) //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); - $j=0; - $level=0; + $j = 0; + $level = 0; $totalforvisibletasks = projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0, $arrayfields, $extrafields); //var_dump($totalforvisibletasks); // Show total for all other tasks // Calculate total for all tasks - $listofdistinctprojectid=array(); // List of all distinct projects + $listofdistinctprojectid = array(); // List of all distinct projects if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { - foreach($tasksarraywithoutfilter as $tmptask) + foreach ($tasksarraywithoutfilter as $tmptask) { - $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); - $totalforeachday=array(); - foreach($listofdistinctprojectid as $tmpprojectid) + $totalforeachday = array(); + foreach ($listofdistinctprojectid as $tmpprojectid) { - $projectstatic->id=$tmpprojectid; - $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $projectstatic->id = $tmpprojectid; + $projectstatic->loadTimeSpent($daytoparse, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($daytoparse, $idw, 'd'); - $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + $tmpday = dol_time_plus_duree($daytoparse, $idw, 'd'); + $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } } //var_dump($totalforeachday); @@ -724,10 +724,10 @@ if (count($tasksarray) > 0) $isdiff = 0; if (count($totalforeachday)) { - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; } } @@ -735,12 +735,12 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; print ''; print ''; print ''; - $tmparray = dol_getdate($daytoparse, true); // detail of current day + $tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $cssonholiday=''; - if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; print ' @@ -794,12 +794,12 @@ print ''; print ''."\n"; print '
        '; -print ''; +print ''; print '
        '; print ''; -$modeinput='hours'; +$modeinput = 'hours'; if ($conf->use_javascript_ajax) { diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 8af733394bf..535f8e17522 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -97,26 +97,26 @@ $next_month = $next['month']; $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow=dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { - $usertoprocess=$user; - $search_usertoprocessid=$usertoprocess->id; + $usertoprocess = $user; + $search_usertoprocessid = $usertoprocess->id; } elseif ($search_usertoprocessid > 0) { - $usertoprocess=new User($db); + $usertoprocess = new User($db); $usertoprocess->fetch($search_usertoprocessid); - $search_usertoprocessid=$usertoprocess->id; + $search_usertoprocessid = $usertoprocess->id; } else { - $usertoprocess=new User($db); + $usertoprocess = new User($db); } -$object=new Task($db); +$object = new Task($db); // Extra fields $extrafields = new ExtraFields($db); @@ -125,7 +125,7 @@ $extrafields = new ExtraFields($db); //$extrafields->fetch_name_optionals_label('projet'); $extrafields->fetch_name_optionals_label('projet_task'); -$arrayfields=array(); +$arrayfields = array(); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -134,8 +134,8 @@ $arrayfields=array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload']=array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -145,17 +145,17 @@ $arrayfields['t.progress']=array('label'=>'ProgressDeclared', 'checked'=>1, 'ena // Extra fields if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { - foreach($extrafields->attributes['projet_task']['label'] as $key => $val) + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { - if (! empty($extrafields->attributes['projet_task']['list'][$key])) - $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key])!=3 && $extrafields->attributes['projet_task']['perms'][$key])); + if (!empty($extrafields->attributes['projet_task']['list'][$key])) + $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); -$search_array_options=array(); -$search_array_options_project=$extrafields->getOptionalsFromPost('projet', '', 'search_'); -$search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); +$search_array_options = array(); +$search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_'); +$search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); @@ -167,7 +167,7 @@ $search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 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 { $action = ''; - $search_categ=''; + $search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -179,7 +179,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options_task = array(); // We redefine $usertoprocess - $usertoprocess=$user; + $usertoprocess = $user; } if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { @@ -209,36 +209,36 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors'); $error++; } - if (! GETPOST('type')) + if (!GETPOST('type')) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - if (! $error) + if (!$error) { - $idfortaskuser=$usertoprocess->id; + $idfortaskuser = $usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) - $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; - $sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; - $resql=$db->query($sql); + $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; + $sql .= ' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); - if (! $obj) // User is not already linked to project, so we will create link to first type + $obj = $db->fetch_object($resql); + if (!$obj) // User is not already linked to project, so we will create link to first type { $project = new Project($db); $project->fetch($object->fk_project); // Get type - $listofprojcontact=$project->liste_type_contact('internal'); + $listofprojcontact = $project->liste_type_contact('internal'); if (count($listofprojcontact)) { - $typeforprojectcontact=reset(array_keys($listofprojcontact)); + $typeforprojectcontact = reset(array_keys($listofprojcontact)); $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal'); } } @@ -264,43 +264,43 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } - if (! $error) + if (!$error) { setEventMessages("TaskAssignedToEnterTime", null); - $taskid=0; + $taskid = 0; } - $action=''; + $action = ''; } if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { - $timetoadd=$_POST['task']; + $timetoadd = $_POST['task']; if (empty($timetoadd)) { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } else { - foreach($timetoadd as $taskid => $value) // Loop on each task + foreach ($timetoadd as $taskid => $value) // Loop on each task { - $updateoftaskdone=0; - foreach($value as $key => $val) // Loop on each day + $updateoftaskdone = 0; + foreach ($value as $key => $val) // Loop on each day { - $amountoadd=$timetoadd[$taskid][$key]; - if (! empty($amountoadd)) + $amountoadd = $timetoadd[$taskid][$key]; + if (!empty($amountoadd)) { - $tmpduration=explode(':', $amountoadd); - $newduration=0; - if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); - if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); - if (! empty($tmpduration[2])) $newduration+=($tmpduration[2]); + $tmpduration = explode(':', $amountoadd); + $newduration = 0; + if (!empty($tmpduration[0])) $newduration += ($tmpduration[0] * 3600); + if (!empty($tmpduration[1])) $newduration += ($tmpduration[1] * 60); + if (!empty($tmpduration[2])) $newduration += ($tmpduration[2]); if ($newduration > 0) { $object->fetch($taskid); - if (GETPOSTISSET($taskid . 'progress')) $object->progress = GETPOST($taskid . 'progress', 'int'); + if (GETPOSTISSET($taskid.'progress')) $object->progress = GETPOST($taskid.'progress', 'int'); else unset($object->progress); $object->timespent_duration = $newduration; @@ -308,7 +308,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); $object->timespent_datehour = $object->timespent_date; - $result=$object->addTimeSpent($user); + $result = $object->addTimeSpent($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -321,14 +321,14 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $updateoftaskdone) // Check to update progress if no update were done on task. + if (!$updateoftaskdone) // Check to update progress if no update were done on task. { $object->fetch($taskid); //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; - if ($object->progress != GETPOST($taskid . 'progress', 'int')) + if ($object->progress != GETPOST($taskid.'progress', 'int')) { - $object->progress = GETPOST($taskid . 'progress', 'int'); - $result=$object->update($user); + $object->progress = GETPOST($taskid.'progress', 'int'); + $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -339,29 +339,29 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $param=''; - $param.=($mode?'&mode='.urlencode($mode):''); - $param.=($projectid?'id='.urlencode($projectid):''); - $param.=($search_usertoprocessid?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($day?'&day='.urlencode($day):'').($month?'&month='.urlencode($month):'').($year?'&year='.urlencode($year):''); - $param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); - $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); - $param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); - $param.=($search_declared_progress?'&search_declared_progress='.urlencode($search_declared_progress):''); - $param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); - $param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); + $param = ''; + $param .= ($mode ? '&mode='.urlencode($mode) : ''); + $param .= ($projectid ? 'id='.urlencode($projectid) : ''); + $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : ''); + $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); + $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); + $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); + $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : ''); + $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); + $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); /*$search_array_options=$search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - $search_array_options=$search_array_options_task; - $search_options_pattern='search_task_options_'; + $search_array_options = $search_array_options_task; + $search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Redirect to avoid submit twice on back @@ -377,19 +377,19 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac * View */ -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); -$formproject=new FormProjets($db); -$projectstatic=new Project($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); +$formproject = new FormProjets($db); +$projectstatic = new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); $holiday = new Holiday($db); -$title=$langs->trans("TimeSpent"); +$title = $langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -397,14 +397,14 @@ if ($id) $project->fetch_thirdparty(); } -$onlyopenedproject=1; // or -1 -$morewherefilter=''; +$onlyopenedproject = 1; // or -1 +$morewherefilter = ''; -if ($search_project_ref) $morewherefilter.=natural_search(array("p.ref", "p.title"), $search_project_ref); -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); -if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); -if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); +if ($search_project_ref) $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref); +if ($search_task_ref) $morewherefilter .= natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label); +if ($search_thirdparty) $morewherefilter .= natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1); $sql = &$morewherefilter; @@ -415,18 +415,18 @@ $extrafieldsobjectkey='projet'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; */ $search_array_options = $search_array_options_task; -$extrafieldsobjectprefix='efpt.'; -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix = 'efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { - $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. + $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. } -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); +$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject); +$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -436,31 +436,31 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project'); -$param=''; -$param.=($mode?'&mode='.urlencode($mode):''); -$param.=($search_project_ref?'&search_project_ref='.urlencode($search_project_ref):''); -$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.urlencode($search_usertoprocessid):''); -$param.=($search_thirdparty?'&search_thirdparty='.urlencode($search_thirdparty):''); -$param.=($search_task_ref?'&search_task_ref='.urlencode($search_task_ref):''); -$param.=($search_task_label?'&search_task_label='.urlencode($search_task_label):''); +$param = ''; +$param .= ($mode ? '&mode='.urlencode($mode) : ''); +$param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); +$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); +$param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); +$param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); -$search_array_options=$search_array_options_project; -$search_options_pattern='search_options_'; +$search_array_options = $search_array_options_project; +$search_options_pattern = 'search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -$search_array_options=$search_array_options_task; -$search_options_pattern='search_task_options_'; +$search_array_options = $search_array_options_task; +$search_options_pattern = 'search_task_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; -$nav.='
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; -$nav.=' '; +$nav = ''.img_previous($langs->trans("Previous"))."\n"; +$nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; +$nav .= ''.img_next($langs->trans("Next"))."\n"; +$nav .= "   (".$langs->trans("Today").")"; +$nav .= '
        '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 0).' '; +$nav .= ' '; -$picto='calendarweek'; +$picto = 'calendarweek'; print ''; print ''; @@ -472,18 +472,18 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode, $usertoprocess); +$head = project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, 'task'); // Show description of content print '
        '; -if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; else { if (empty($usertoprocess->id) || $usertoprocess->id < 0) { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; - else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
        '; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; + else print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'
        '; } } if ($mine || ($usertoprocess->id == $user->id)) @@ -498,13 +498,13 @@ print '
        '; dol_fiche_end(); -print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. +print '
        '.$nav.'
        '; // We move this before the assign to components so, the default submit button is not the assign to. print '
        '; $titleassigntask = $langs->transnoentities("AssignTaskToMe"); if ($usertoprocess->id != $user->id) $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs)); print '
        '; -$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); +$formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, 1, 1, 0, 0, '', '', 'all', $usertoprocess); print '
        '; print ' '; print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); @@ -514,13 +514,13 @@ print '
        '; print '
        '; -$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); +$startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); // Get if user is available or not for each day -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +$isavailable = array(); +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; @@ -528,9 +528,9 @@ if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) } } -for ($idw=0; $idw<7; $idw++) +for ($idw = 0; $idw < 7; $idw++) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow @@ -543,11 +543,11 @@ for ($idw=0; $idw<7; $idw++) $statusofholidaytocheck = '3'; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); - $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day + $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day } -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories /* @@ -561,96 +561,96 @@ if (! empty($conf->categorie->enabled)) }*/ // If the user can view user other than himself -$moreforfilter.='
        '; -$moreforfilter.='
        '.$langs->trans('User'). '
        '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='
        '; +$moreforfilter .= '
        '; +$moreforfilter .= '
        '.$langs->trans('User').'
        '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '
        '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('Project'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('Project').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; - $moreforfilter.='
        '; - $moreforfilter.='
        '.$langs->trans('ThirdParty'). '
        '; - $moreforfilter.=''; - $moreforfilter.='
        '; + $moreforfilter .= '
        '; + $moreforfilter .= '
        '.$langs->trans('ThirdParty').'
        '; + $moreforfilter .= ''; + $moreforfilter .= '
        '; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
        '; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
        '; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields // This must be after the $selectedfields -$addcolspan=0; -if (! empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; -if (! empty($arrayfields['t.progress']['checked'])) $addcolspan++; +$addcolspan = 0; +if (!empty($arrayfields['t.planned_workload']['checked'])) $addcolspan++; +if (!empty($arrayfields['t.progress']['checked'])) $addcolspan++; foreach ($arrayfields as $key => $val) { if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; } print '
        '; -print '
        '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
        ('.$langs->trans("Everybody").')
        '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
        ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
        '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
        ('.dol_trunc($usertoprocess->firstname, 10).')' : '').'
        '.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to -$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); +$restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); // Get if user is available or not for each day -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +$isavailable = array(); +if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { $numstartworkingday = $tmparray[0]; @@ -624,59 +624,59 @@ if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) } $statusofholidaytocheck = '3'; -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 -$isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 +$isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$tmparray = dol_getdate($daytoparse, true); // detail of current day +$tmparray = dol_getdate($daytoparse, true); // detail of current day $idw = $tmparray['wday']; -$cssweekend=''; +$cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } -$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); +$tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); -$cssonholiday=''; -if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; -elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; -elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; +$cssonholiday = ''; +if (!$isavailable[$daytoparse]['morning'] && !$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayallday '; +elseif (!$isavailable[$daytoparse]['morning']) $cssonholiday .= 'onholidaymorning '; +elseif (!$isavailable[$daytoparse]['afternoon']) $cssonholiday .= 'onholidayafternoon '; -print ''.$langs->trans("Duration").''.$langs->trans("Duration").''.$langs->trans("Note").'
        '; + print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); + $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); //if ($timeonothertasks) //{ print ''; - print ''; + print ''; print $langs->trans("Total"); print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
        '."\n"; +print '
        '."\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$search_options_pattern='search_task_options_'; -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$search_options_pattern = 'search_task_options_'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; print ''; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } print ''; -for ($idw=0;$idw<7;$idw++) +for ($idw = 0; $idw < 7; $idw++) { print ''; } // Action column print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; // TASK fields -$extrafieldsobjectkey='projet_task'; -$extrafieldsobjectprefix='efpt.'; +$extrafieldsobjectkey = 'projet_task'; +$extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -if (! empty($arrayfields['t.planned_workload']['checked'])) +if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; } -if (! empty($arrayfields['t.progress']['checked'])) +if (!empty($arrayfields['t.progress']['checked'])) { print ''; } @@ -658,27 +658,27 @@ if (! empty($arrayfields['t.progress']['checked'])) if ($usertoprocess->id == $user->id) print ''; else print '';*/ print ''; -print ''; +print ''; -for ($idw=0; $idw<7; $idw++) +for ($idw = 0; $idw < 7; $idw++) { - $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; } //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -686,32 +686,32 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan=3+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); +$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $cssonholiday=''; - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; - print ''; + print ''; } print ''; print ''; @@ -720,39 +720,39 @@ if ($conf->use_javascript_ajax) // By default, we can edit only tasks we are assigned to -$restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); +$restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); if (count($tasksarray) > 0) { //var_dump($tasksarray); // contains only selected tasks //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter) //var_dump($tasksrole); - $j=0; - $level=0; + $j = 0; + $level = 0; $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields); //var_dump($totalforvisibletasks); // Show total for all other tasks // Calculate total for all tasks - $listofdistinctprojectid=array(); // List of all distinct projects + $listofdistinctprojectid = array(); // List of all distinct projects if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) { - foreach($tasksarraywithoutfilter as $tmptask) + foreach ($tasksarraywithoutfilter as $tmptask) { - $listofdistinctprojectid[$tmptask->fk_project]=$tmptask->fk_project; + $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project; } } //var_dump($listofdistinctprojectid); - $totalforeachday=array(); - foreach($listofdistinctprojectid as $tmpprojectid) + $totalforeachday = array(); + foreach ($listofdistinctprojectid as $tmpprojectid) { - $projectstatic->id=$tmpprojectid; - $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $projectstatic->id = $tmpprojectid; + $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $totalforeachday[$tmpday]+=$projectstatic->weekWorkLoad[$tmpday]; + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; } } @@ -765,11 +765,11 @@ if (count($tasksarray) > 0) { for ($idw = 0; $idw < 7; $idw++) { - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { - $isdiff=1; + $isdiff = 1; break; } } @@ -779,20 +779,20 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) { - $cssweekend=''; + $cssweekend = ''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { - $cssweekend='weekend'; + $cssweekend = 'weekend'; } - print ''; // Categories - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print '"; @@ -1095,11 +1095,11 @@ elseif ($object->id > 0) print ''; // Change probability from status - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Default value to close or not when we set opp to 'WON'. - $defaultcheckedwhenoppclose=1; - if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; + $defaultcheckedwhenoppclose = 1; + if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0; print ''; print ''; print ''."\n"; } -if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT) -|| ! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) +if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) +|| !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount=0; - if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount=$conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } - if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount=GETPOST('amount')?GETPOST('amount'):$conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; } // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''; print ''; - if (isset($object->photo) && $object->photo !='') + if (isset($object->photo) && $object->photo != '') { $form = new Form($db); print '
        '; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
        '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
        ('.$langs->trans("Everybody").')
        '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
        ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
        '.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
        ('.dol_trunc($usertoprocess->firstname, 10).')' : '').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
        '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
        '; + print ''; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
         
         
         
        '; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); + print ''; + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) { print 'use_javascript_ajax) { @@ -865,7 +865,7 @@ if ($conf->use_javascript_ajax) } });'."\n"; - $idw=0; + $idw = 0; while ($idw < 7) { print ' updateTotal('.$idw.',\''.$modeinput.'\');'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 51af2f2b14d..74f53cc9b72 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -94,9 +94,9 @@ if (empty($reshook)) // Cancel if ($cancel) { - if (GETPOST("comefromclone")==1) + if (GETPOST("comefromclone") == 1) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: index.php"); @@ -119,7 +119,7 @@ if (empty($reshook)) if ($action == 'add' && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($_POST["ref"])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); @@ -131,21 +131,21 @@ if (empty($reshook)) $error++; } - if (GETPOST('opp_amount') != '' && ! (GETPOST('opp_status') > 0)) + if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0)) { $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } // Create with status validated immediatly - if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT)) + if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT)) { - $status=Project::STATUS_VALIDATED; + $status = Project::STATUS_VALIDATED; } - if (! $error) + if (!$error) { - $error=0; + $error = 0; $db->begin(); @@ -156,23 +156,23 @@ if (empty($reshook)) $object->public = GETPOST('public', 'alpha'); $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); - $object->date_c = dol_now(); + $object->date_c = dol_now(); $object->date_start = $date_start; $object->date_end = $date_end; $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; $result = $object->create($user); - if (! $error && $result > 0) + if (!$error && $result > 0) { // Add myself as project leader $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); @@ -189,19 +189,19 @@ if (empty($reshook)) setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } - if (! $error && !empty($object->id) > 0) + if (!$error && !empty($object->id) > 0) { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); - if ($result<0) { + $result = $object->setCategories($categories); + if ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; } } - if (! $error) + if (!$error) { $db->commit(); @@ -231,9 +231,9 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) { - $error=0; + $error = 0; if (empty($ref)) { @@ -250,7 +250,7 @@ if (empty($reshook)) $db->begin(); - if (! $error) + if (!$error) { $object->oldcopy = clone $object; @@ -260,18 +260,18 @@ if (empty($reshook)) $object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is $object->statut = GETPOST('status', 'int'); $object->socid = GETPOST('socid', 'int'); - $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is + $object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public', 'alpha'); - $object->date_start = empty($_POST["projectstart"])?'':$date_start; - $object->date_end = empty($_POST["projectend"])?'':$date_end; + $object->date_start = empty($_POST["projectstart"]) ? '' : $date_start; + $object->date_end = empty($_POST["projectend"]) ? '' : $date_end; if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha')); - if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount', 'alpha')); + if (isset($_POST['budget_amount'])) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; - $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0); - $object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0); - $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0); - $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0); + $object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0); + $object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0); + $object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0); + $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -284,18 +284,18 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result < 0) { $error++; if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); else setEventMessages($object->error, $object->errors, 'errors'); - }else { + } else { // Category association $categories = GETPOST('categories', 'array'); - $result=$object->setCategories($categories); + $result = $object->setCategories($categories); if ($result < 0) { $error++; @@ -304,11 +304,11 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) + if (GETPOST("reportdate") && ($object->date_start != $old_start_date)) { - $result=$object->shiftTaskDate($old_start_date); + $result = $object->shiftTaskDate($old_start_date); if ($result < 0) { $error++; @@ -332,7 +332,7 @@ if (empty($reshook)) if ($error) { $db->rollback(); - $action='edit'; + $action = 'edit'; } else { @@ -355,11 +355,11 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result= $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -368,11 +368,11 @@ if (empty($reshook)) { if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $conf->projet->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); + $file = $upload_dir.'/'.GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); @@ -413,7 +413,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { $object->fetch($id); - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -429,15 +429,15 @@ if (empty($reshook)) if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { - $clone_contacts=GETPOST('clone_contacts')?1:0; - $clone_tasks=GETPOST('clone_tasks')?1:0; + $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; + $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; $clone_task_files = GETPOST('clone_task_files') ? 1 : 0; - $clone_notes=GETPOST('clone_notes')?1:0; - $move_date=GETPOST('move_date')?1:0; - $clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0; + $clone_notes = GETPOST('clone_notes') ? 1 : 0; + $move_date = GETPOST('move_date') ? 1 : 0; + $clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0; - $result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); + $result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -445,21 +445,21 @@ if (empty($reshook)) else { // Load new object - $newobject=new Project($db); + $newobject = new Project($db); $newobject->fetch($result); $newobject->fetch_optionals(); - $newobject->fetch_thirdparty(); // Load new object - $object=$newobject; - $action='edit'; - $comefromclone=true; + $newobject->fetch_thirdparty(); // Load new object + $object = $newobject; + $action = 'edit'; + $comefromclone = true; } } // Actions to send emails - $trigger_name='PROJECT_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add - $trackid='proj'.$object->id; + $trigger_name = 'PROJECT_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add + $trackid = 'proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -473,21 +473,21 @@ $formfile = new FormFile($db); $formproject = new FormProjets($db); $userstatic = new User($db); -$title=$langs->trans("Project").' - '.$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title=$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:''); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : ''); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$titleboth=$langs->trans("LeadsOrProjects"); -$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default +$titleboth = $langs->trans("LeadsOrProjects"); +$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { - $titleboth=$langs->trans("Projects"); + $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only - $titleboth=$langs->trans("Leads"); + $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); } @@ -497,7 +497,7 @@ if ($action == 'create' && $user->rights->projet->creer) * Create */ - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); if ($socid > 0) $thirdparty->fetch($socid); print load_fiche_titre($titlenew, '', 'project'); @@ -511,18 +511,18 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // 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/project/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -530,16 +530,16 @@ if ($action == 'create' && $user->rights->projet->creer) if ($filefound) { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; $defaultref = $modProject->getNextValue($thirdparty, $object); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; // Ref - $suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref); + $suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref); print ''; @@ -552,23 +552,23 @@ if ($action == 'create' && $user->rights->projet->creer) print $langs->trans("Usage"); print ''; print ''; // Date start print ''; // Date end print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; print ''; // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Budget print ''; - print ''; + print ''; print ''; // Description @@ -664,14 +664,14 @@ if ($action == 'create' && $user->rights->projet->creer) // Categories print '"; } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -684,7 +684,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
        '; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -692,7 +692,7 @@ if ($action == 'create' && $user->rights->projet->creer) else { print '     '; - print ''; + print ''; } print '
        '; @@ -721,7 +721,7 @@ elseif ($object->id > 0) * Show or edit */ - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // To verify role of users $userAccess = $object->restrictedProjectArea($user, 'read'); @@ -748,26 +748,26 @@ elseif ($object->id > 0) // Confirmation delete if ($action == 'delete') { - $text=$langs->trans("ConfirmDeleteAProject"); - $task=new Task($db); - $taskarray=$task->getTasksArray(0, 0, $object->id, 0, 0); - $nboftask=count($taskarray); - if ($nboftask) $text.='
        '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); + $text = $langs->trans("ConfirmDeleteAProject"); + $task = new Task($db); + $taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0); + $nboftask = count($taskarray); + if ($nboftask) $text .= '
        '.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1); } // Clone confirmation if ($action == 'clone') { - $formquestion=array( + $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), - array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), - array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans("CloneProjectFiles"), 'value' => false), - array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), + array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false), + array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); @@ -803,9 +803,9 @@ elseif ($object->id > 0) // Status print ''; @@ -815,23 +815,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status print ''; @@ -881,33 +881,33 @@ elseif ($object->id > 0) // Opportunity probability print ''; - print ''; print ''; // Opportunity amount print ''; - print ''; + print ''; print ''; } // Date start print ''; // Date end print ''; // Budget print ''; - print ''; + print ''; print ''; // Description @@ -923,7 +923,7 @@ elseif ($object->id > 0) $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PROJECT); - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -931,8 +931,8 @@ elseif ($object->id > 0) } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -943,28 +943,28 @@ elseif ($object->id > 0) } else { - dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); // Project card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
        '; + $morehtmlref = '
        '; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty - $morehtmlref.='
        '.$langs->trans('ThirdParty') . ' : '; + $morehtmlref .= '
        '.$langs->trans('ThirdParty').' : '; if ($object->thirdparty->id > 0) { $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
        '; + $morehtmlref .= '
        '; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -981,23 +981,23 @@ elseif ($object->id > 0) print $langs->trans("Usage"); print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES) && ! empty($object->usage_opportunity)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) { // Opportunity status print ''; @@ -1050,7 +1050,7 @@ elseif ($object->id > 0) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
        '.$langs->trans("Ref").''; print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); print '
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -584,16 +584,16 @@ if ($action == 'create' && $user->rights->projet->creer) if ($conf->societe->enabled) { print '
        '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); } else print $text; @@ -612,46 +612,46 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility print '
        '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); - print $form->selectarray('public', $array, GETPOST('public')?GETPOST('public'):$object->public); + print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public); print '
        '.$langs->trans("DateStart").''; - print $form->selectDate(($date_start?$date_start:''), 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("DateEnd").''; - print $form->selectDate(($date_end?$date_end:-1), 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("OpportunityStatus").''; - print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status')?GETPOST('opp_status'):$object->opp_status); + print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status); print '
        '.$langs->trans("OpportunityProbability").' %'; - print ''; + print ' %'; + print ''; print '
        '.$langs->trans("OpportunityAmount").'
        '.$langs->trans("Budget").'
        '.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); - $arrayselected=GETPOST('categories', 'array'); + $arrayselected = GETPOST('categories', 'array'); print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print "
        '.$langs->trans("Status").''; print ''; print '
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -842,16 +842,16 @@ elseif ($object->id > 0) if ($conf->societe->enabled) { print '
        '; - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print $langs->trans("ThirdParty"); - print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':''); + print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : ''); print ''; - $filteronlist=''; - if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; - $text=$form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); + $filteronlist = ''; + if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; + $text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300'); if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) { - $texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty"); + $texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty"); print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); } else print $text; @@ -860,13 +860,13 @@ elseif ($object->id > 0) // Visibility print '
        '.$langs->trans("Visibility").''; - $array=array(); + $array = array(); if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); print $form->selectarray('public', $array, $object->public); print '
        '.$langs->trans("OpportunityStatus").'
        '.$langs->trans("OpportunityProbability").' %'; + print ' %'; print ''; print '
        '.$langs->trans("OpportunityAmount").'
        '.$langs->trans("DateStart").''; - print $form->selectDate($object->date_start?$object->date_start:-1, 'projectstart', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0); print '     '. $langs->trans("ProjectReportDate"); + if ($comefromclone) {print ' checked '; } + print '/> '.$langs->trans("ProjectReportDate"); print '
        '.$langs->trans("DateEnd").''; - print $form->selectDate($object->date_end?$object->date_end:-1, 'projectend', 0, 0, 0, '', 1, 0); + print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0); print '
        '.$langs->trans("Budget").'
        '; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
        '; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
        '; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
        '; @@ -1010,7 +1010,7 @@ elseif ($object->id > 0) else print $langs->trans('PrivateProject'); print '
        '.$langs->trans("OpportunityStatus").''; @@ -1036,10 +1036,10 @@ elseif ($object->id > 0) // Date start - end print '
        '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'day'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'day'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
        '; @@ -1067,7 +1067,7 @@ elseif ($object->id > 0) print '
        '.$langs->trans("Categories").''; print $form->showCategories($object->id, 'project', 1); print "
        '.$langs->trans("Subscription").''; - if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { print ''; } @@ -730,7 +730,7 @@ dol_fiche_end(); // Save print '
        '; print ''; -if (! empty($backtopage)) +if (!empty($backtopage)) { print '     '; } diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index e10186458fa..32a83e5c432 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -25,14 +25,14 @@ * \brief File to show a public card of a member */ -if (! defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +if (!defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. +if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -46,7 +46,7 @@ if (empty($conf->adherent->enabled)) accessforbidden('', 0, 0, 1); $langs->loadLangs(array("main", "members", "companies", "other")); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $object = new Adherent($db); $extrafields = new ExtraFields($db); @@ -64,9 +64,9 @@ $extrafields = new ExtraFields($db); * View */ -$morehead=''; -if (! empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead=''; -else $morehead=''; +$morehead = ''; +if (!empty($conf->global->MEMBER_PUBLIC_CSS)) $morehead = ''; +else $morehead = ''; llxHeaderVierge($langs->trans("MemberCard"), $morehead); @@ -75,9 +75,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($id > 0) { - $res=$object->fetch($id); + $res = $object->fetch($id); if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); print load_fiche_titre($langs->trans("MemberCard"), '', ''); @@ -101,7 +101,7 @@ if ($id > 0) print '
        '.$langs->trans("EMail").''.$object->email.' 
        '.$langs->trans("Birthday").''.dol_print_date($object->birth, 'day').'
        URL Photo'; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 9829aa03f7b..834d5aa67ee 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","other","ticket")); +$langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); @@ -117,7 +117,7 @@ if ($action == "view_ticketlist") { } } if ($object->fk_user_create > 0) { - $tmpuser=new User($db); + $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_create); if ($email == $tmpuser->email) { $display_ticket_list = true; @@ -159,7 +159,7 @@ $user_create = new User($db); $formTicket = new FormTicket($db); if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { - print '
        ' . $langs->trans('TicketPublicInterfaceForbidden') . '
        '; + print '
        '.$langs->trans('TicketPublicInterfaceForbidden').'
        '; $db->close(); exit(); } @@ -235,50 +235,50 @@ if ($action == "view_ticketlist") if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') { - $arrayfields["ef." . $key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => $extrafields->attributes[$object->table_element]['list'][$key], 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $extrafields->attributes[$object->table_element]['perms'][$key]); + $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => $extrafields->attributes[$object->table_element]['list'][$key], 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => $extrafields->attributes[$object->table_element]['perms'][$key]); } } } if (!empty($search_subject)) { $filter['t.subject'] = $search_subject; - $param .= '&search_subject=' .urlencode($search_subject); + $param .= '&search_subject='.urlencode($search_subject); } if (!empty($search_type)) { $filter['t.type_code'] = $search_type; - $param .= '&search_type=' . urlencode($search_type); + $param .= '&search_type='.urlencode($search_type); } if (!empty($search_category)) { $filter['t.category_code'] = $search_category; - $param .= '&search_category=' . urlencode($search_category); + $param .= '&search_category='.urlencode($search_category); } if (!empty($search_severity)) { $filter['t.severity_code'] = $search_severity; - $param .= '&search_severity=' . urlencode($search_severity); + $param .= '&search_severity='.urlencode($search_severity); } if (!empty($search_fk_user_assign)) { // -1 value = all so no filter if ($search_fk_user_assign > 0) { $filter['t.fk_user_assign'] = $search_fk_user_assign; - $param .= '&search_fk_user_assign=' . urlencode($search_fk_user_assign); + $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign); } } if (!empty($search_fk_user_create)) { // -1 value = all so no filter if ($search_fk_user_create > 0) { $filter['t.fk_user_create'] = $search_fk_user_create; - $param .= '&search_fk_user_create=' . urlencode($search_fk_user_create); + $param .= '&search_fk_user_create='.urlencode($search_fk_user_create); } } if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') { $filter['t.fk_statut'] = $search_fk_status; - $param .= '&search_fk_status=' . urlencode($search_fk_status); + $param .= '&search_fk_status='.urlencode($search_fk_status); } if (isset($search_fk_status) && $search_fk_status == 'non_closed') { $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6); $param .= '&search_fk_status=non_closed'; } - require DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -325,54 +325,54 @@ if ($action == "view_ticketlist") // Add fields for extrafields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($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 .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as uc ON uc.rowid=t.fk_user_create"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as ua ON ua.rowid=t.fk_user_assign"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id=t.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople sp ON ec.fk_socpeople=sp.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid=t.fk_user_assign"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id=t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople=sp.rowid"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "ticket_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; } - $sql .= " WHERE t.entity IN (" . getEntity('ticket') . ")"; + $sql .= " WHERE t.entity IN (".getEntity('ticket').")"; $sql .= " AND ((tc.source = 'external'"; - $sql .= " AND tc.element='" . $db->escape($object->dao->element) . "'"; + $sql .= " AND tc.element='".$db->escape($object->dao->element)."'"; $sql .= " AND tc.active=1)"; - $sql .= " OR (sp.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR s.email='" . $db->escape($_SESSION['email_customer']) . "'"; - $sql .= " OR t.origin_email='" . $db->escape($_SESSION['email_customer']) . "'))"; + $sql .= " OR (sp.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'"; + $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."'))"; // Manage filter if (!empty($filter)) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) { - $sql .= " AND " . $key . " = '" . $db->escape($value) ."'"; + $sql .= " AND ".$key." = '".$db->escape($value)."'"; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { - $sql .= 'AND ' . $key . ' IN (' . implode(',', $value) . ')'; + $sql .= 'AND '.$key.' IN ('.implode(',', $value).')'; } else { - $sql .= ' AND ' . $key . ' = ' . $db->escape($value); + $sql .= ' AND '.$key.' = '.$db->escape($value); } } else { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } } } //$sql .= " GROUP BY t.track_id"; - $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder; + $sql .= " ORDER BY ".$sortfield.' '.$sortorder; $resql = $db->query($sql); if ($resql) { $num_total = $db->num_rows($resql); if (!empty($limit)) { - $sql .= ' ' . $db->plimit($limit + 1, $offset); + $sql .= ' '.$db->plimit($limit + 1, $offset); } $resql = $db->query($sql); @@ -381,16 +381,16 @@ if ($action == "view_ticketlist") print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); // Search bar - print '
        ' . "\n"; + print ''."\n"; print ''; print ''; - print ''; - print ''; + print ''; + print ''; $varpage = empty($contextpage) ? $url_page_current : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''; + print '
        '; // Filter bar print ''; @@ -412,7 +412,7 @@ if ($action == "view_ticketlist") if (!empty($arrayfields['t.subject']['checked'])) { print ''; } @@ -454,8 +454,8 @@ if ($action == "view_ticketlist") include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status @@ -468,7 +468,7 @@ if ($action == "view_ticketlist") // Action column print ''; print ''; @@ -516,8 +516,8 @@ if ($action == "view_ticketlist") include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['t.fk_statut']['checked'])) { @@ -561,7 +561,7 @@ if ($action == "view_ticketlist") // Subject if (!empty($arrayfields['t.subject']['checked'])) { print ''; } @@ -620,20 +620,20 @@ if ($action == "view_ticketlist") } if (!empty($arrayfields['t.tms']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($arrayfields["ef." . $key]['checked'])) { + if (!empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); if ($align) { - print ' align="' . $align . '"'; + print ' align="'.$align.'"'; } print '>'; - $tmpkey = 'options_' . $key; + $tmpkey = 'options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; } @@ -657,8 +657,8 @@ if ($action == "view_ticketlist") print '
        '; - print ''; + print ''; print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
        '; - print '' . $obj->subject . ''; + print ''.$obj->subject.''; print '' . dol_print_date($db->jdate($obj->tms), 'dayhour') . ''.dol_print_date($db->jdate($obj->tms), 'dayhour').'
        '; print '
        '; - print '