diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index faab333890b..8321b28ef04 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -24,15 +24,15 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -55,24 +55,24 @@ $object = new AccountingAccount($db); if (GETPOST('cancel', 'alpha')) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); header("Location: ".$urltogo); exit; } if ($action == 'add' && $user->rights->accounting->chartofaccount) { - if (! $cancel) { - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + if (!$cancel) { + $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + dol_syslog('accountancy/admin/card.php:: $sql='.$sql); $result = $db->query($sql); $obj = $db->fetch_object($result); // Clean code // To manage zero or not at the end of the accounting account - if($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { $account_number = GETPOST('account_number', 'string'); } @@ -116,28 +116,28 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; } - if (! $error) + if (!$error) { setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); header("Location: ".$urltogo); exit; } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { - if (! $cancel) { + if (!$cancel) { $result = $object->fetch($id); - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; + $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + dol_syslog('accountancy/admin/card.php:: $sql='.$sql); $result2 = $db->query($sql); $obj = $db->fetch_object($result2); // Clean code // To manage zero or not at the end of the accounting account - if($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { $account_number = GETPOST('account_number', 'string'); } @@ -166,21 +166,21 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $result = $object->update($user); if ($result > 0) { - $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: " . $urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } else { $mesg = $object->error; } } else { - $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: " . $urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } } elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) { $result = $object->fetch($id); - if (! empty($object->id)) { + if (!empty($object->id)) { $result = $object->delete($user); if ($result > 0) { @@ -205,7 +205,7 @@ $formaccounting = new FormAccounting($db); $accountsystem = new AccountancySystem($db); $accountsystem->fetch($conf->global->CHARTOFACCOUNTS); -$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card'); +$title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card'); $helpurl = ''; llxheader('', $title, $helpurl); @@ -214,8 +214,8 @@ llxheader('', $title, $helpurl); if ($action == 'create') { print load_fiche_titre($langs->trans('NewAccountingAccount')); - print '
' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; dol_fiche_head(); @@ -223,41 +223,41 @@ if ($action == 'create') { print ''; // Chart of account - print ''; + print ''; print ''; // Account number - print ''; - print ''; + print ''; + print ''; // Label - print ''; - print ''; + print ''; + print ''; // Account parent - print ''; + print ''; print ''; // Category - print ''; + print ''; print ''; // Chart of accounts type - print ''; + print ''; print ''; // Chart of acounts subtype - print ''; + print ''; print ''; print '
' . $langs->trans("Chartofaccounts") . '
'.$langs->trans("Chartofaccounts").''; print $accountsystem->ref; print '
' . $langs->trans("AccountNumber") . '
'.$langs->trans("AccountNumber").'
' . $langs->trans("Label") . '
'.$langs->trans("Label").'
' . $langs->trans("Accountparent") . '
'.$langs->trans("Accountparent").''; print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200'); print '
' . $langs->trans("AccountingCategory") . '
'.$langs->trans("AccountingCategory").''; $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); print '
' . $langs->trans("Pcgtype") . '
'.$langs->trans("Pcgtype").''; - print ''; + print ''; print '
' . $langs->trans("Pcgsubtype") . '
'.$langs->trans("Pcgsubtype").''; - print ''; + print ''; print '
'; @@ -265,9 +265,9 @@ if ($action == 'create') { dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print '
'; @@ -285,24 +285,24 @@ elseif ($id > 0 || $ref) { { dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - print '
' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Account number - print ''; - print ''; + print ''; + print ''; // Label - print ''; - print ''; + print ''; + print ''; // Account parent - print ''; + print ''; print ''; @@ -314,15 +314,15 @@ elseif ($id > 0 || $ref) { print ''; // Chart of accounts type - print ''; + print ''; print ''; // Chart of accounts subtype - print ''; + print ''; print ''; print '
' . $langs->trans("AccountNumber") . '
'.$langs->trans("AccountNumber").'
' . $langs->trans("Label") . '
'.$langs->trans("Label").'
' . $langs->trans("Accountparent") . '
'.$langs->trans("Accountparent").''; print $formaccounting->select_account($object->account_parent, 'account_parent', 1); print '
' . $langs->trans("Pcgtype") . '
'.$langs->trans("Pcgtype").''; - print ''; + print ''; print '
' . $langs->trans("Pcgsubtype") . '
'.$langs->trans("Pcgsubtype").''; - print ''; + print ''; print '
'; @@ -330,15 +330,15 @@ elseif ($id > 0 || $ref) { dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print '
'; } else { // View mode - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); @@ -351,27 +351,27 @@ elseif ($id > 0 || $ref) { print ''; // Label - print ''; - print ''; + print ''; + print ''; // Account parent $accp = new AccountingAccount($db); - if (! empty($object->account_parent)) { + if (!empty($object->account_parent)) { $accp->fetch($object->account_parent, ''); } - print ''; - print ''; + print ''; + print ''; // Category print ""; // Chart of accounts type - print ''; - print ''; + print ''; + print ''; // Chart of accounts subtype - print ''; - print ''; + print ''; + print ''; print '
' . $langs->trans("Label") . '' . $object->label . '
'.$langs->trans("Label").''.$object->label.'
' . $langs->trans("Accountparent") . '' . $accp->account_number . ' - ' . $accp->label . '
'.$langs->trans("Accountparent").''.$accp->account_number.' - '.$accp->label.'
".$langs->trans("AccountingCategory")."".$object->account_category_label."
' . $langs->trans("Pcgtype") . '' . $object->pcg_type . '
'.$langs->trans("Pcgtype").''.$object->pcg_type.'
' . $langs->trans("Pcgsubtype") . '' . $object->pcg_subtype . '
'.$langs->trans("Pcgsubtype").''.$object->pcg_subtype.'
'; @@ -384,16 +384,16 @@ elseif ($id > 0 || $ref) { */ print '
'; - if (! empty($user->rights->accounting->chartofaccount)) { - print '' . $langs->trans('Modify') . ''; + if (!empty($user->rights->accounting->chartofaccount)) { + print ''.$langs->trans('Modify').''; } else { - print '' . $langs->trans('Modify') . ''; + print ''.$langs->trans('Modify').''; } - if (! empty($user->rights->accounting->chartofaccount)) { - print '' . $langs->trans('Delete') . ''; + if (!empty($user->rights->accounting->chartofaccount)) { + print ''.$langs->trans('Delete').''; } else { - print '' . $langs->trans('Delete') . ''; + print ''.$langs->trans('Delete').''; } print '
'; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 8313a45a504..7bbcf80ff1f 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -23,14 +23,14 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $mesg = ''; $id = GETPOST('id', 'int'); @@ -59,16 +59,16 @@ $accountingcategory = new AccountancyCategory($db); */ // si ajout de comptes -if (! empty($selectcpt)) { +if (!empty($selectcpt)) { $cpts = array(); foreach ($selectcpt as $selectedoption) { - if (! array_key_exists($selectedoption, $cpts)) - $cpts[$selectedoption] = "'" . $selectedoption . "'"; + if (!array_key_exists($selectedoption, $cpts)) + $cpts[$selectedoption] = "'".$selectedoption."'"; } - $return= $accountingcategory->updateAccAcc($cat_id, $cpts); + $return = $accountingcategory->updateAccAcc($cat_id, $cpts); - if ($return<0) { + if ($return < 0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs'); @@ -98,8 +98,8 @@ $linkback = '' . "\n"; -print ''; +print '
'."\n"; +print ''; print ''; dol_fiche_head(); @@ -107,26 +107,26 @@ dol_fiche_head(); print ''; // Select the category -print ''; +print ''; print ''; // Select the accounts -if (! empty($cat_id)) +if (!empty($cat_id)) { $return = $accountingcategory->getAccountsWithNoCategory($cat_id); if ($return < 0) { setEventMessages(null, $accountingcategory->errors, 'errors'); } - print ''; + print ''; print ''; } @@ -158,8 +158,8 @@ if ($action == 'display' || $action == 'delete') { print '"; print "\n"; - if (! empty($cat_id)) { - $return = $accountingcategory->display($cat_id); // This load ->lines_display + if (!empty($cat_id)) { + $return = $accountingcategory->display($cat_id); // This load ->lines_display if ($return < 0) { setEventMessages(null, $accountingcategory->errors, 'errors'); } @@ -167,10 +167,10 @@ if ($action == 'display' || $action == 'delete') { if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) { foreach ($accountingcategory->lines_display as $cpt) { print ''; - print ''; - print ''; + print ''; + print ''; print ''; - if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { // TODO ADJUST DESCRIPTION SIZE // print ''; // TODO: we shoul set a user defined value to adjust user square / wide screen size $trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print ''; + print ''; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 1d77a9a2186..f27d535f57c 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -26,11 +26,11 @@ */ 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/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other")); // Filter $year = GETPOST("year", 'int'); @@ -49,17 +49,17 @@ if ($year == 0) { llxHeader('', $langs->trans("Bookkeeping")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear); +print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear); -$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " , " . MAIN_DB_PREFIX . "facture as f"; +$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE fd.fk_code_ventilation = 0"; $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; -dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql); +dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql); $result = $db->query($sql); if ($result) { $row = $db->fetch_row($result); @@ -72,10 +72,10 @@ $y = $year_current; print '
' . $langs->trans("AccountingCategory") . '
'.$langs->trans("AccountingCategory").''; $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); -print ''; +print ''; print '
' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '
'.$langs->trans("AddAccountFromBookKeepingWithNoCategories").''; - $arraykeyvalue=array(); - foreach($accountingcategory->lines_cptbk as $key => $val) + $arraykeyvalue = array(); + foreach ($accountingcategory->lines_cptbk as $key => $val) { - $arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte) . ' (' . $val->label_compte . ($val->doc_ref?' '.$val->doc_ref:'').')'; + $arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')'; } if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { @@ -139,7 +139,7 @@ if (! empty($cat_id)) print '
'; print ajax_combobox('cpt_bk'); */ - print ' '; + print ' '; } print '
'.$langs->trans("Label")."
' . length_accountg($cpt->account_number) . '' . $cpt->label . ''.length_accountg($cpt->account_number).''.$cpt->label.''; - print ""; + print "rowid."'>"; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink'); print ""; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 8cda5284ba8..94664374a05 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -28,12 +28,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/accountancyexport.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/accountancyexport.class.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)) @@ -57,7 +57,7 @@ $listformat = $configuration['format']; $listcr = $configuration['cr']; -$model_option = array ( +$model_option = array( '1' => array( 'label' => 'ACCOUNTING_EXPORT_FORMAT', 'param' => $listformat, @@ -86,37 +86,37 @@ if ($action == 'update') { $modelcsv = GETPOST('ACCOUNTING_EXPORT_MODELCSV', 'int'); - if (! empty($modelcsv)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!empty($modelcsv)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { + $error++; } //if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) { // dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity); //} } else { - $error ++; + $error++; } foreach ($main_option as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } foreach ($listparam[$modelcsv] as $key => $value) { $constante = $key; - if (strpos($constante, 'ACCOUNTING')!==false) { + if (strpos($constante, 'ACCOUNTING') !== false) { $constvalue = GETPOST($key, 'alpha'); - if (! dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } } - if (! $error) { + if (!$error) { // reload $configuration = AccountancyExport::getTypeConfig(); $listparam = $configuration['param']; @@ -138,7 +138,7 @@ $title = $langs->trans('ConfigAccountingExpert'); llxHeader('', $title); -$linkback=''; +$linkback = ''; // $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); @@ -187,8 +187,8 @@ print ' });'."\n"; print '})'."\n"; print ''."\n"; -print ''; -print ''; +print ''; +print ''; print ''; /* @@ -197,7 +197,7 @@ print ''; print ''; print ''; -print ''; +print ''; print "\n"; $num = count($main_option); @@ -207,11 +207,11 @@ if ($num) { // Param $label = $langs->trans($key); - print ''; + print ''; // Value print ''; } } @@ -226,13 +226,13 @@ print "
\n"; print '
' . $langs->trans('Options') . ''.$langs->trans('Options').'
' . $label . ''.$label.''; - print ''; + print ''; print '
'; print ''; -print ''; +print ''; print ''; print ''; -print ''; -if (! $conf->use_javascript_ajax) { +print ''; +if (!$conf->use_javascript_ajax) { print '"; @@ -256,7 +256,7 @@ $num2 = count($model_option); if ($num2) { print '
' . $langs->trans("Modelcsv") . ''.$langs->trans("Modelcsv").'
' . $langs->trans("Selectmodelcsv") . ''.$langs->trans("Selectmodelcsv").''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print "
'; print ''; - print ''; + print ''; print "\n"; foreach ($model_option as $key) { @@ -264,14 +264,14 @@ if ($num2) { // Param $label = $key['label']; - print ''; + print ''; // Value print ''; @@ -280,7 +280,7 @@ if ($num2) { print "
' . $langs->trans('OtherOptions') . ''.$langs->trans('OtherOptions').'
' . $langs->trans($label) . ''.$langs->trans($label).''; if (is_array($key['param'])) { print $form->selectarray($label, $key['param'], $conf->global->$label, 0); } else { - print ''; + print ''; } print '
\n"; } -print '
'; +print '
'; print ''; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 6d321e60756..7dd4ae1a935 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -22,13 +22,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; $action = GETPOST('action', 'aZ09'); // 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'); @@ -36,32 +36,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="f.rowid"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; // Load translation files required by the page -$langs->loadLangs(array("admin","compta")); +$langs->loadLangs(array("admin", "compta")); // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. +if (!$user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. accessforbidden(); $error = 0; // List of status -static $tmpstatut2label = array ( +static $tmpstatut2label = array( '0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear' ); -$statut2label = array ( +$statut2label = array( '' ); foreach ($tmpstatut2label as $key => $val) $statut2label[$key] = $langs->trans($val); -$errors = array (); +$errors = array(); $object = new Fiscalyear($db); @@ -85,9 +85,9 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; -$sql .= " WHERE f.entity = " . $conf->entity; -$sql.=$db->order($sortfield, $sortorder); +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f"; +$sql .= " WHERE f.entity = ".$conf->entity; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -102,7 +102,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -112,7 +112,7 @@ if ($result) $i = 0; - $addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); + $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $title = $langs->trans('AccountingPeriods'); @@ -122,34 +122,34 @@ if ($result) print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($num) { $fiscalyearstatic = new Fiscalyear($db); - while ( $i < $num && $i < $max ) { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); $fiscalyearstatic->id = $obj->rowid; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; $i++; } } else { - print ''; + print ''; } print '
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("DateStart") . '' . $langs->trans("DateEnd") . '' . $langs->trans("NumberOfAccountancyEntries") . '' . $langs->trans("NumberOfAccountancyMovements") . '' . $langs->trans("Statut") . ''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("NumberOfAccountancyEntries").''.$langs->trans("NumberOfAccountancyMovements").''.$langs->trans("Statut").'
' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '' . $obj->label . '' . dol_print_date($db->jdate($obj->date_start), 'day') . '' . dol_print_date($db->jdate($obj->date_end), 'day') . '' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . ''.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.''.$obj->label.''.dol_print_date($db->jdate($obj->date_start), 'day').''.dol_print_date($db->jdate($obj->date_end), 'day').''.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).''.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).''.$fiscalyearstatic->LibStatut($obj->statut, 5).'
' . $langs->trans("None") . '
'.$langs->trans("None").'
'; print '
'; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 31000b8ec8a..3656a8f16a2 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -24,11 +24,11 @@ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","compta")); +$langs->loadLangs(array("admin", "compta")); // Security check if ($user->socid > 0) @@ -43,11 +43,11 @@ $confirm = GETPOST('confirm', 'alpha'); $id = GETPOST('id', 'int'); // List of statut -static $tmpstatut2label = array ( +static $tmpstatut2label = array( '0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear' ); -$statut2label = array ( +$statut2label = array( '' ); foreach ($tmpstatut2label as $key => $val) @@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } elseif ($action == 'add') { - if (! GETPOST('cancel', 'alpha')) { + if (!GETPOST('cancel', 'alpha')) { $error = 0; $object->date_start = $date_start; @@ -85,14 +85,14 @@ elseif ($action == 'add') { if (empty($object->date_start) && empty($object->date_end)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error ++; + $error++; } if (empty($object->label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $error ++; + $error++; } - if (! $error) { + if (!$error) { $db->begin(); $id = $object->create($user); @@ -100,7 +100,7 @@ elseif ($action == 'add') { if ($id > 0) { $db->commit(); - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } else { $db->rollback(); @@ -119,7 +119,7 @@ elseif ($action == 'add') { // Update record elseif ($action == 'update') { - if (! GETPOST('cancel', 'alpha')) { + if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; @@ -130,13 +130,13 @@ elseif ($action == 'update') { $result = $object->update($user); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit(); } } @@ -149,7 +149,7 @@ elseif ($action == 'update') { $form = new Form($db); -$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); +$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card"); $helpurl = ""; llxHeader("", $title, $helpurl); @@ -157,8 +157,8 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); - print '
'; - print ''; + print ''; + print ''; print ''; dol_fiche_head(); @@ -166,15 +166,15 @@ if ($action == 'create') print ''; // Label - print ''; + print ''; // Date start - print ''; // Date end - print ''; @@ -192,9 +192,9 @@ if ($action == 'create') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -206,36 +206,36 @@ if ($action == 'create') if ($action == 'edit') { dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; - print ''; + print ''; print '
' . $langs->trans("Label") . '
'.$langs->trans("Label").'
' . $langs->trans("DateStart") . ''; + print '
'.$langs->trans("DateStart").''; print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; + print '
'.$langs->trans("DateEnd").''; print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend'); print '
'; // Ref print ""; - print ''; // Label - print ''; // Date start - print ''; // Date end - print ''; // Statut - print ''; @@ -243,9 +243,9 @@ if ($action == 'create') print '
' . $langs->trans("Ref") . ''; + print ''.$langs->trans("Ref").''; print $object->ref; print '
' . $langs->trans("Label") . ''; - print ''; + print '
'.$langs->trans("Label").''; + print ''; print '
' . $langs->trans("DateStart") . ''; + print '
'.$langs->trans("DateStart").''; print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; + print '
'.$langs->trans("DateEnd").''; print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print '
' . $langs->trans("Statut") . ''; + print '
'.$langs->trans("Statut").''; // print $form->selectarray('statut', $statut2label, $object->statut); print $object->getLibStatut(4); print '
'; print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -256,17 +256,17 @@ if ($action == 'create') * Confirm delete */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); } dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print ''; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; // Ref - print ''; // Statut - print ''; + print ''; print "
' . $langs->trans("Ref") . ''; + print '
'.$langs->trans("Ref").''; print $object->ref; print ''; print $linkback; @@ -294,20 +294,20 @@ if ($action == 'create') print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
"; dol_fiche_end(); - if (! empty($user->rights->accounting->fiscalyear->write)) + if (!empty($user->rights->accounting->fiscalyear->write)) { /* * Barre d'actions */ print '
'; - print '' . $langs->trans('Modify') . ''; + print ''.$langs->trans('Modify').''; // print '' . $langs->trans('Delete') . ''; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index dcc2e608f0b..d4630c4505f 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'); } } @@ -85,10 +85,10 @@ if ($action == 'update') { if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; + if (!$res > 0) + $error++; - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'mesgs'); @@ -98,9 +98,9 @@ if ($action == 'setlistsorttodo') { if ($action == 'setlistsortdone') { $setlistsortdone = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, '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'); @@ -110,9 +110,9 @@ if ($action == 'setlistsortdone') { if ($action == 'setmanagezero') { $setmanagezero = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, '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'); @@ -122,9 +122,9 @@ if ($action == 'setmanagezero') { if ($action == 'setdisabledirectinput') { $setdisabledirectinput = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, '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'); @@ -134,9 +134,9 @@ if ($action == 'setdisabledirectinput') { if ($action == 'setenabledraftexport') { $setenabledraftexport = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, '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'); @@ -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/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 6fedd7706d0..13abe51ccaf 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -26,22 +26,22 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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 . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","compta","accountancy","products")); +$langs->loadLangs(array("companies", "compta", "accountancy", "products")); // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); } -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // search & action GETPOST @@ -77,23 +77,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; -if (empty($action)) $action='list'; +if (empty($action)) $action = 'list'; -$arrayfields=array(); +$arrayfields = 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'); // Purge search criteria @@ -110,10 +110,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' // Sales or Purchase mode ? if ($action == 'update') { - if (! empty($btn_changetype)) { + if (!empty($btn_changetype)) { $error = 0; - $accounting_product_modes = array ( + $accounting_product_modes = array( 'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL_INTRA', 'ACCOUNTANCY_SELL_EXPORT', @@ -121,17 +121,17 @@ if ($action == 'update') { ); if (in_array($accounting_product_mode, $accounting_product_modes)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } } - if (! empty($btn_changeaccount)) { + if (!empty($btn_changeaccount)) { //$msg = '
' . $langs->trans("Processing") . '...
'; - if (! empty($chk_prod)) { + if (!empty($chk_prod)) { $accounting = new AccountingAccount($db); //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; @@ -140,37 +140,37 @@ if ($action == 'update') { $cpt = 0; $ok = 0; $ko = 0; foreach ($chk_prod as $productid) { - $accounting_account_id = GETPOST('codeventil_' . $productid); + $accounting_account_id = GETPOST('codeventil_'.$productid); $result = 0; if ($accounting_account_id > 0) { - $arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id; + $arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id; $result = $accounting->fetch($accounting_account_id, null, 1); } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { $db->begin(); - $sql = " UPDATE " . MAIN_DB_PREFIX . "product"; + $sql = " UPDATE ".MAIN_DB_PREFIX."product"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " SET accountancy_code_buy = " . $accounting->account_number; + $sql .= " SET accountancy_code_buy = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql .= " SET accountancy_code_sell = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; } if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $sql .= " SET accountancy_code_sell_export = " . $accounting->account_number; + $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; } - $sql .= " WHERE rowid = " . $productid; + $sql .= " WHERE rowid = ".$productid; - dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { $ok++; @@ -305,24 +305,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql .= $db->plimit($limit + 1, $offset); -dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); +dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref); - if ($search_label > 0) $param.="&search_desc=".urlencode($search_label); - if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); - if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account); - if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid); - if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); + if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); + if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); + if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); + if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); + if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -497,13 +497,13 @@ if ($result) print '
'.$obj->label.'' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''.nl2br(dol_trunc($obj->description, $trunclengh)).'
'; print ''; -print ''; -for($i = 1; $i <= 12; $i++) +print ''; +for ($i = 1; $i <= 12; $i++) { - print ''; + print ''; } print ''; print ''; @@ -94,9 +94,9 @@ $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',"; $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',"; $sql .= " ROUND(SUM(bk.montant),2) as 'Total'"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; -$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; -$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; +$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; +$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; $sql .= " GROUP BY bk.numero_compte"; $resql = $db->query($sql); @@ -104,26 +104,26 @@ if ($resql) { $i = 0; $num = $db->num_rows($resql); - while ( $i < $num ) { + while ($i < $num) { $row = $db->fetch_row($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - $i ++; + $i++; } $db->free($resql); } else { diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 35c556807f8..39ed325b5fe 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -23,12 +23,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 . '/accountancy/class/bookkeeping.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.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear->write) +if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); -$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); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -69,54 +69,54 @@ $year_current = $year_start; llxHeader('', $langs->trans("Closure")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("Closure")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescClosure") . '
'; +print ''.$langs->trans("DescClosure").'
'; print '
'; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateMovements") . ''; +$buttonbind = ''.$langs->trans("ValidateMovements").''; print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); print '
'; print '
' . $langs->trans("Label") . ''.$langs->trans("Label").'' . $langs->trans("MonthShort".sprintf("%02s", $i)) . ''.$langs->trans("MonthShort".sprintf("%02s", $i)).''.$langs->trans("Total").'
' . length_accountg($row[0]) . '' . price($row[1]) . '' . price($row[2]) . '' . price($row[3]) . '' . price($row[4]) . '' . price($row[5]) . '' . price($row[6]) . '' . price($row[7]) . '' . price($row[8]) . '' . price($row[9]) . '' . price($row[10]) . '' . price($row[11]) . '' . price($row[12]) . '' . price($row[13]) . '
'.length_accountg($row[0]).''.price($row[1]).''.price($row[2]).''.price($row[3]).''.price($row[4]).''.price($row[5]).''.price($row[6]).''.price($row[7]).''.price($row[8]).''.price($row[9]).''.price($row[10]).''.price($row[11]).''.price($row[12]).''.price($row[13]).'
'; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; $sql = "SELECT COUNT(b.rowid) as detail,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; +$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; +$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy -dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 0b079c57b20..fe7fda5054f 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -23,12 +23,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 . '/accountancy/class/bookkeeping.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.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); - if (! $user->rights->accounting->fiscalyear->write) + if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); -$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); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -68,14 +68,14 @@ if ($action == 'validate') // Update database $db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '" . $db->idate($now) . "'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '".$db->idate($now)."'"; $sql .= ' WHERE b.date_validated IS NULL'; dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); $resql = $db->query($sql); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -91,13 +91,13 @@ if ($action == 'validate') llxHeader('', $langs->trans("ValidateMovements")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print $langs->trans("DescValidateMovements") . '
'; +print $langs->trans("DescValidateMovements").'
'; print '
'; @@ -108,38 +108,38 @@ print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', ' print '
'; print '
' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[$i] . ''.$row[$i].'' . $row[13] . ''.$row[13].'
'; print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; print ''; $sql = "SELECT COUNT(b.rowid) as detail,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; +$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; +$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; +$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy -dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - for($i = 1; $i <= 12; $i ++) { - print '' ; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; } $db->free($resql); @@ -149,7 +149,7 @@ if ($resql) { print ''; print "
' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[$i] . '

'; - print ''; - print '
'.$row[$i].'

'; + print ''; + print '
' . $row[13] . ''.$row[13].'
\n"; -print '
'; +print '
'; print ''; // End of page diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 6b64d969518..eb7156eee82 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -24,11 +24,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.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.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -48,16 +48,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -93,18 +93,18 @@ $form = new Form($db); $facture_static = new Facture($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,"; $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; - $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -114,8 +114,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -126,15 +126,15 @@ if (! empty($id)) { print ''; // Ref facture - print ''; + print ''; $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; print '
' . $langs->trans("Invoice") . '
'.$langs->trans("Invoice").'' . $facture_static->getNomUrl(1) . ''.$facture_static->getNomUrl(1).'
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; + print '
'.$langs->trans("Line").''.nl2br($objp->description).'
'.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; @@ -142,9 +142,9 @@ if (! empty($id)) { dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2aa6072f2c2..49bda732640 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -27,13 +27,13 @@ */ 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/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.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/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$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); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -121,26 +121,26 @@ if ($action == 'validatehistory') { // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; - $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; - $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -172,12 +172,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -206,64 +206,64 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("CustomersVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("CustomersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilCustomer") . '
'; -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; +print ''.$langs->trans("DescVentilCustomer").'
'; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
'; print '

'; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND f.fk_statut > 0"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -301,34 +301,34 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -278,11 +278,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; @@ -338,7 +338,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -380,31 +380,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -355,11 +355,11 @@ if ($resql) { else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("TotalVente")."' AS total,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } dol_syslog('htdocs/accountancy/customer/index.php'); @@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); @@ -428,35 +428,35 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print ''; - if (! empty($conf->margin->enabled)) { + if (!empty($conf->margin->enabled)) { print "
\n"; print '
'; print '
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("TotalVente").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[0] . '' . price($row[$i]) . '
'.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
'; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("Vide")."' AS marge,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } dol_syslog('htdocs/accountancy/customer/index.php'); @@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 0d0e6509769..5d9bc60c6ac 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -28,11 +28,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy","trips")); +$langs->loadLangs(array("bills", "accountancy", "trips")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -52,16 +52,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -95,18 +95,18 @@ $form = new Form($db); $expensereport_static = new ExpenseReport($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,"; $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,"; $sql .= " aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id; - $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".$id; + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/expensereport/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -116,8 +116,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -128,22 +128,22 @@ if (! empty($id)) { print '
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("TotalMarge").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[0] . '' . price(price2num($row[$i])) . '
'.$row[0].''.price(price2num($row[$i])).'' . price(price2num($row[13])) . ''.price(price2num($row[13])).'
'; // Ref - print ''; + print ''; $expensereport_static->ref = $objp->ref; $expensereport_static->id = $objp->erid; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; print '
' . $langs->trans("ExpenseReport") . '
'.$langs->trans("ExpenseReport").'' . $expensereport_static->getNomUrl(1) . ''.$expensereport_static->getNomUrl(1).'
' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->rowid)) . '
'.$langs->trans("Line").''.stripslashes(nl2br($objp->rowid)).'
' . $langs->trans("Description") . '' . stripslashes(nl2br($objp->comments)) . '
'.$langs->trans("Description").''.stripslashes(nl2br($objp->comments)).'
' . $langs->trans("TypeFees") . '' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '
'.$langs->trans("TypeFees").''.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'
' . $langs->trans("Account") . ''; + print '
'.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; @@ -151,9 +151,9 @@ if (! empty($id)) { dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 29fe4a7aea3..2f22344e8fb 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -25,12 +25,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 . '/expensereport/class/expensereport.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.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -38,15 +38,15 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$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); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -72,19 +72,19 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'expensereport WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -99,16 +99,16 @@ if ($action == 'validatehistory') { // Now make the binding if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; + $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "expensereport_det.fk_code_ventilation = 0"; + $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd, " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; $sql1 .= " AND erd.fk_code_ventilation = 0"; } @@ -116,8 +116,8 @@ if ($action == 'validatehistory') { dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -133,19 +133,19 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("ExpenseReportsVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("ExpenseReportsVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilExpenseReport") . '
'; -print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; +print ''.$langs->trans("DescVentilExpenseReport").'
'; +print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
'; print '

'; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -153,39 +153,39 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', print '
'; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(erd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; -$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; +$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); +dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -200,11 +200,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " ROUND(SUM(erd.total_ht),2) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; -$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; +$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; @@ -256,7 +256,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -298,27 +298,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -272,11 +272,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(erd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; + $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; - $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql = $db->query($sql); @@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index e39decd7c57..622ac801fbc 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -28,11 +28,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","accountancy")); +$langs->loadLangs(array("bills", "accountancy")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -52,16 +52,16 @@ if ($user->socid > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { - if (! $cancel) + if (!$cancel) { if ($codeventil < 0) $codeventil = 0; - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; + $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; $resql = $db->query($sql); - if (! $resql) { + if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else @@ -95,18 +95,18 @@ $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); $formaccounting = new FormAccounting($db); -if (! empty($id)) { +if (!empty($id)) { $sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= ", aa.account_number, aa.label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; - $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; - $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn "; + $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id; + $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy - dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); + dol_syslog("/accounting/supplier/card.php sql=".$sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -116,8 +116,8 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - print '' . "\n"; - print ''; + print ''."\n"; + print ''; print ''; print ''; @@ -128,17 +128,17 @@ if (! empty($id)) { print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[0] . '' . price($row[$i]) . '
'.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
'; // ref invoice - print ''; + print ''; $facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->id = $objp->facid; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print '
' . $langs->trans("BillsSuppliers") . '
'.$langs->trans("BillsSuppliers").'' . $facturefournisseur_static->getNomUrl(1) . ''.$facturefournisseur_static->getNomUrl(1).'
' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->description)) . '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; + print '
'.$langs->trans("Line").''.stripslashes(nl2br($objp->description)).'
'.$langs->trans("ProductLabel").''.dol_trunc($objp->product_label, 24).'
'.$langs->trans("Account").''; print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; @@ -146,9 +146,9 @@ if (! empty($id)) { dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 945c5567b0b..2955ddec881 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -25,13 +25,13 @@ */ 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/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.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/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -39,16 +39,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$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); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -75,19 +75,19 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture_fourn WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -118,24 +118,24 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; - $sql.= " aa.rowid as aarowid,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; + $sql .= " aa.rowid as aarowid,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/supplier/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -171,12 +171,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -205,18 +205,18 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("SuppliersVentilation")); -$textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textprevyear = ''.img_previous().''; +$textnextyear = ' '.img_next().''; -print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); +print load_fiche_titre($langs->trans("SuppliersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); -print ''.$langs->trans("DescVentilSupplier") . '
'; -print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; +print ''.$langs->trans("DescVentilSupplier").'
'; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'
'; print '

'; $y = $year_current; -$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -224,30 +224,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', print '
'; print ''; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; -$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; -$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -256,7 +256,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -294,30 +294,30 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -271,11 +271,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; -print ''; -print ''; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; +print ''; +print ''; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } -print ''; +print ''; -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,"; -$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,"; -for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; -$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; -$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; +$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; -$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; @@ -326,7 +326,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; - for($i = 2; $i <= 12; $i++) { - print ''; + for ($i = 2; $i <= 12; $i++) { + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } $db->free($resql); @@ -367,27 +367,27 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. print '
'; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Account").''.$langs->trans("Label").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
'; if ($row[0] == 'tobind') { @@ -341,11 +341,11 @@ if ($resql) { } else print $row[1]; print '' . price($row[$i]) . ''.price($row[$i]).'' . price($row[13]) . '' . price($row[14]) . ''.price($row[13]).''.price($row[14]).'
'; - print ''; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; } - print ''; + print ''; - $sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,"; - for($i = 1; $i <= 12; $i ++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1; - if ($j > 12) $j-=12; - $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ","; + $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } $sql .= " SUM(ffd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; - $sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'"; - $sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'"; + $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; $sql .= " AND ff.fk_statut > 0"; - $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); @@ -395,11 +395,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; } - print ''; + print ''; print ''; } $db->free($resql); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index aa203ffca42..bca4236bfa2 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -27,29 +27,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -if (! empty($conf->banque->enabled)) { +if (!empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("companies","members","bills","users")); +$langs->loadLangs(array("companies", "members", "bills", "users")); $adh = new Adherent($db); $adht = new AdherentType($db); $object = new Subscription($db); -$errmsg=''; +$errmsg = ''; -$action=GETPOST("action", 'alpha'); -$rowid=GETPOST("rowid", "int")?GETPOST("rowid", "int"):GETPOST("id", "int"); -$typeid=GETPOST("typeid", "int"); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm'); +$action = GETPOST("action", 'alpha'); +$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int"); +$typeid = GETPOST("typeid", "int"); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm'); -if (! $user->rights->adherent->cotisation->lire) +if (!$user->rights->adherent->cotisation->lire) accessforbidden(); $permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php @@ -57,60 +57,60 @@ $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the i * Actions */ -if ($cancel) $action=''; +if ($cancel) $action = ''; //include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once -if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel) +if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel) { // Load current object - $result=$object->fetch($rowid); + $result = $object->fetch($rowid); if ($result > 0) { $db->begin(); - $errmsg=''; + $errmsg = ''; if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); // If transaction consolidated if ($accountline->rappro) { - $errmsg=$langs->trans("SubscriptionLinkedToConciliatedTransaction"); + $errmsg = $langs->trans("SubscriptionLinkedToConciliatedTransaction"); } else { - $accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->amount=$_POST["amount"]; - $result=$accountline->update($user); + $accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $accountline->amount = $_POST["amount"]; + $result = $accountline->update($user); if ($result < 0) { - $errmsg=$accountline->error; + $errmsg = $accountline->error; } } } - if (! $errmsg) + if (!$errmsg) { // Modify values - $object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); - $object->fk_type=$_POST["typeid"]; - $object->note=$_POST["note"]; - $object->amount=$_POST["amount"]; + $object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); + $object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); + $object->fk_type = $_POST["typeid"]; + $object->note = $_POST["note"]; + $object->amount = $_POST["amount"]; //print 'datef='.$object->datef.' '.$_POST['datesubendday']; - $result=$object->update($user); - if ($result >= 0 && ! count($object->errors)) + $result = $object->update($user); + if ($result >= 0 && !count($object->errors)) { $db->commit(); @@ -123,17 +123,17 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc if ($object->error) { - $errmsg=$object->error; + $errmsg = $object->error; } else { - foreach($object->errors as $error) + foreach ($object->errors as $error) { - if ($errmsg) $errmsg.='
'; - $errmsg.=$error; + if ($errmsg) $errmsg .= '
'; + $errmsg .= $error; } } - $action=''; + $action = ''; } } else @@ -145,8 +145,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) { - $result=$object->fetch($rowid); - $result=$object->delete($user); + $result = $object->fetch($rowid); + $result = $object->delete($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); @@ -154,7 +154,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent- } else { - $mesg=$adh->error; + $mesg = $adh->error; } } @@ -182,7 +182,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') ********************************************/ $object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); + $result = $adh->fetch($object->fk_adherent); $head = subscription_prepare_head($object); @@ -206,7 +206,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print ''; // Member - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print ''; print ''; print ''; @@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Type print ''; print ''; // Date start subscription @@ -238,15 +238,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print ''; // Bank line - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print '
' . $langs->trans("Total") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'' . $langs->trans("Total") . '
'.$langs->trans("Total").'
' . $row[0] . '' . price($row[$i]) . '
'.$row[0].''.price($row[$i]).'' . price($row[13]) . ''.price($row[13]).'
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Type").''; - print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); + print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"]) ? $_POST["typeid"] : $object->fk_type)); print'
'.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall'); } else @@ -279,8 +279,8 @@ if ($rowid && $action != 'edit') * ********************************************/ - $result=$object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); + $result = $object->fetch($rowid); + $result = $adh->fetch($object->fk_adherent); $head = subscription_prepare_head($object); @@ -291,8 +291,8 @@ if ($rowid && $action != 'edit') { //$formquestion=array(); //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; - $text=$langs->trans("ConfirmDeleteSubscription"); - if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='
'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); + $text = $langs->trans("ConfirmDeleteSubscription"); + if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '
'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1); } @@ -310,7 +310,7 @@ if ($rowid && $action != 'edit') print ''; // Member - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print ''; print ''; print ''; @@ -345,15 +345,15 @@ if ($rowid && $action != 'edit') print ''; // Bank line - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print ''; print '
'; @@ -626,7 +626,7 @@ if ($rowid > 0) $moreforfilter = ''; print '
'; - print '
'.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').'
'.$langs->trans("Label").''.$object->note.'
'.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall'); } else @@ -379,7 +379,7 @@ if ($rowid && $action != 'edit') if ($user->rights->adherent->cotisation->creer) { - if (! $bankline->rappro) + if (!$bankline->rappro) { print '"; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 0c1ec419a32..d98dcd9f693 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -41,35 +41,35 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$search_lastname = GETPOST('search_lastname', 'alpha'); +$search_lastname = GETPOST('search_lastname', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_email = GETPOST('search_email', 'alpha'); -$type = GETPOST('type', 'intcomma'); +$type = GETPOST('type', 'intcomma'); $status = GETPOST('status', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder="DESC"; } -if (! $sortfield) { $sortfield="d.lastname"; } +if (!$sortorder) { $sortorder = "DESC"; } +if (!$sortfield) { $sortfield = "d.lastname"; } -$label=GETPOST("label", "alpha"); -$morphy=GETPOST("morphy", "alpha"); -$statut=GETPOST("statut", "int"); -$subscription=GETPOST("subscription", "int"); +$label = GETPOST("label", "alpha"); +$morphy = GETPOST("morphy", "alpha"); +$statut = GETPOST("statut", "int"); +$subscription = GETPOST("subscription", "int"); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); -$vote=GETPOST("vote", "int"); -$comment=GETPOST("comment", 'alphanohtml'); -$mail_valid=GETPOST("mail_valid", 'none'); +$vote = GETPOST("vote", "int"); +$comment = GETPOST("comment", 'alphanohtml'); +$mail_valid = GETPOST("mail_valid", 'none'); // Security check -$result=restrictedArea($user, 'adherent', $rowid, 'adherent_type'); +$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); $object = new AdherentType($db); @@ -80,16 +80,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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_lastname=""; - $search_login=""; - $search_email=""; - $type=""; - $sall=""; + $search_lastname = ""; + $search_login = ""; + $search_email = ""; + $type = ""; + $sall = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membertypecard','globalcard')); +$hookmanager->initHooks(array('membertypecard', 'globalcard')); /* @@ -97,23 +97,23 @@ $hookmanager->initHooks(array('membertypecard','globalcard')); */ if ($cancel) { - $action=''; + $action = ''; - if (! empty($backtopage)) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } } if ($action == 'add' && $user->rights->adherent->configurer) { - $object->label = trim($label); + $object->label = trim($label); $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); + $object->mail_valid = trim($mail_valid); $object->vote = (int) $vote; // Fill array 'array_options' with data from add form @@ -137,9 +137,9 @@ if ($action == 'add' && $user->rights->adherent->configurer) { } } - if (! $error) + if (!$error) { - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -164,22 +164,22 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->oldcopy = clone $object; $object->label = trim($label); - $object->morphy = trim($morphy); + $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); + $object->mail_valid = trim($mail_valid); $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $ret=$object->update($user); + $ret = $object->update($user); - if ($ret >= 0 && ! count($object->errors)) + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs'); } @@ -195,7 +195,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) if ($action == 'confirm_delete' && $user->rights->adherent->configurer) { $object->fetch($rowid); - $res=$object->delete(); + $res = $object->delete(); if ($res > 0) { @@ -206,7 +206,7 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) else { setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); - $action=''; + $action = ''; } } @@ -215,20 +215,20 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) * View */ -$form=new Form($db); +$form = new Form($db); $formproduct = new FormProduct($db); llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); // List of members type -if (! $rowid && $action != 'create' && $action != 'edit') +if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) @@ -240,10 +240,10 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->adherent->configurer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); } print '
'; @@ -260,7 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; print ''; print ''; @@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; print ''; // Morphy @@ -351,7 +351,7 @@ if ($action == 'create') $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '"; print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -433,7 +433,7 @@ if ($rowid > 0) print '
'.$langs->trans("Ref").''.yn($objp->subscription).''.yn($objp->vote).''; - if ( !empty($objp->statut) ) { + if (!empty($objp->statut)) { print img_picto($langs->trans("InActivity"), 'statut4'); } else { print img_picto($langs->trans("ActivityCeased"), 'statut5'); @@ -343,7 +343,7 @@ if ($action == 'create') print '
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1); + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print '
'.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy); print "
'.$langs->trans("SubscriptionRequired").''; @@ -372,13 +372,13 @@ if ($action == 'create') print '
'.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
'; print ''; 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("Status").''; - if ( !empty($object->statut) ) { + if (!empty($object->statut)) { print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity"); } else { print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased"); @@ -455,13 +455,13 @@ if ($rowid > 0) print '
'.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($object->duration_value > 0) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } - print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; + print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print '
'.$langs->trans("Description").''; @@ -471,7 +471,7 @@ if ($rowid > 0) print nl2br($object->mail_valid)."
'; print '
'; @@ -491,7 +491,7 @@ if ($rowid > 0) } // Add - if ( $user->rights->adherent->configurer && !empty($object->statut) ) + if ($user->rights->adherent->configurer && !empty($object->statut)) { print ''; } else { @@ -509,55 +509,55 @@ if ($rowid > 0) // Show list of members (nearly same code than in page list.php) - $membertypestatic=new AdherentType($db); + $membertypestatic = new AdherentType($db); - $now=dol_now(); + $now = dol_now(); $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,"; - $sql.= " d.datefin,"; - $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; - $sql.= " t.libelle as type, t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_adherent_type = t.rowid "; - $sql.= " AND d.entity IN (".getEntity('adherent').")"; - $sql.= " AND t.rowid = ".$object->id; + $sql .= " d.datefin,"; + $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; + $sql .= " t.libelle as type, t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE d.fk_adherent_type = t.rowid "; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + $sql .= " AND t.rowid = ".$object->id; if ($sall) { - $sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall); + $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { - $sql.= natural_search('d.statut', $status, 2); + $sql .= natural_search('d.statut', $status, 2); } if ($action == 'search') { if (GETPOST('search', 'alpha')) { - $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search', 'alpha')); + $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha')); } } - if (! empty($search_lastname)) + if (!empty($search_lastname)) { - $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname); + $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname); } - if (! empty($search_login)) + if (!empty($search_login)) { - $sql.= natural_search("d.login", $search_login); + $sql .= natural_search("d.login", $search_login); } - if (! empty($search_email)) + if (!empty($search_email)) { - $sql.= natural_search("d.email", $search_email); + $sql .= natural_search("d.email", $search_email); } if ($filter == 'uptodate') { - $sql.=" AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; + $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; } if ($filter == 'outofdate') { - $sql.=" AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; } - $sql.= " ".$db->order($sortfield, $sortorder); + $sql .= " ".$db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -573,7 +573,7 @@ if ($rowid > 0) } } - $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); + $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -581,35 +581,35 @@ if ($rowid > 0) $num = $db->num_rows($resql); $i = 0; - $titre=$langs->trans("MembersList"); + $titre = $langs->trans("MembersList"); if ($status != '') { - if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - elseif ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } - elseif ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - elseif ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - elseif ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - elseif ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } + if ($status == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + elseif ($status == '-1') { $titre = $langs->trans("MembersListToValid"); } + elseif ($status == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + elseif ($status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + elseif ($status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + elseif ($status == '0') { $titre = $langs->trans("MembersListResiliated"); } } elseif ($action == 'search') { - $titre=$langs->trans("MembersListQualified"); + $titre = $langs->trans("MembersListQualified"); } if ($type > 0) { - $membertype=new AdherentType($db); - $result=$membertype->fetch($type); - $titre.=" (".$membertype->label.")"; + $membertype = new AdherentType($db); + $result = $membertype->fetch($type); + $titre .= " (".$membertype->label.")"; } - $param="&rowid=".$object->id; - if (! empty($status)) $param.="&status=".$status; - if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; - if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; - if (! empty($search_login)) $param.="&search_login=".$search_login; - if (! empty($search_email)) $param.="&search_email=".$search_email; - if (! empty($filter)) $param.="&filter=".$filter; + $param = "&rowid=".$object->id; + if (!empty($status)) $param .= "&status=".$status; + if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; + if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; + if (!empty($search_login)) $param .= "&search_login=".$search_login; + if (!empty($search_email)) $param .= "&search_email=".$search_email; + if (!empty($filter)) $param .= "&filter=".$filter; if ($sall) { @@ -617,7 +617,7 @@ if ($rowid > 0) } print ''; - print ''; + print ''; print '
'."\n"; + print '
'."\n"; // Fields title search print ''; @@ -666,11 +666,11 @@ if ($rowid > 0) { $objp = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); + $datefin = $db->jdate($objp->datefin); - $adh=new Adherent($db); - $adh->lastname=$objp->lastname; - $adh->firstname=$objp->firstname; + $adh = new Adherent($db); + $adh->lastname = $objp->lastname; + $adh->firstname = $objp->firstname; // Lastname print ''; @@ -794,7 +794,7 @@ if ($rowid > 0) print ''; print ''; // Morphy @@ -802,7 +802,7 @@ if ($rowid > 0) $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '"; print '"; // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // 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)) { diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 08504a39df6..b70327271f0 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -35,15 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $langs->loadLangs(array('members', 'languages')); $id = GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; // Security check -$result=restrictedArea($user, 'adherent', $id, 'adherent_type'); +$result = restrictedArea($user, 'adherent', $id, 'adherent_type'); /* @@ -105,21 +105,21 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a foreach ($object->multilangs as $key => $value) // saving new values in the object { - if ( $key == $current_lang ) + if ($key == $current_lang) { $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); } } - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -135,10 +135,10 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights- { $object = new AdherentType($db); $object->fetch($id); - $langtodelete=GETPOST('langdel', 'alpha'); + $langtodelete = GETPOST('langdel', 'alpha'); - if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + if ($object->delMultiLangs($langtodelete, $user) > 0) { $action = ''; } @@ -161,20 +161,20 @@ $title = $langs->trans('MemberTypeCard'); $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); -$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation'); -$helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('MemberType')." ".$shortlabel." - ".$langs->trans('Translation'); +$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; llxHeader('', $title, $helpurl); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); $head = member_type_prepare_head($object); -$titre=$langs->trans("MemberType".$object->type); +$titre = $langs->trans("MemberType".$object->type); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -224,12 +224,12 @@ if ($action == 'edit') print ''; print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
"; + $s = picto_from_langcode($key); + print "
".($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
"; print '
'; print '
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut); + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut); print '
'.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy); print "
'.$langs->trans("SubscriptionRequired").''; @@ -823,16 +823,16 @@ if ($rowid > 0) print '
'.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print "
'; @@ -255,12 +255,12 @@ if ($action == 'edit') } elseif ($action != 'add') { - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + $s = picto_from_langcode($key); + print ($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; print '
'; print '
'; @@ -271,7 +271,7 @@ elseif ($action != 'add') print '
'; } } - if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; + if (!$cnt_trans && $action != 'add') print '
'.$langs->trans('NoTranslation').'
'; } diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 0a87f4eda17..65e9cc88856 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -41,9 +41,9 @@ $search_event = GETPOST('search_event', 'alpha'); // Get list of triggers available $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; -$sql.= " ORDER BY a.rang ASC"; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; +$sql .= " ORDER BY a.rang ASC"; +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -51,11 +51,11 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - $triggers[$i]['rowid'] = $obj->rowid; + $triggers[$i]['rowid'] = $obj->rowid; $triggers[$i]['code'] = $obj->code; - $triggers[$i]['element'] = $obj->elementtype; - $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); - $triggers[$i]['position'] = $obj->position; + $triggers[$i]['element'] = $obj->elementtype; + $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); + $triggers[$i]['position'] = $obj->position; $i++; } @@ -74,35 +74,35 @@ else */ // 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_event = ''; $action = ''; } -if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') ||GETPOST('button_search', 'alpha')) // To avoid the save when we click on search +if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search { $action = ''; } if ($action == "save" && empty($cancel)) { - $i=0; + $i = 0; $db->begin(); foreach ($triggers as $trigger) { - $keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; + $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; //print "param=".$param." - ".$_POST[$param]; if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) { - $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha')?GETPOST($keyparam, 'alpha'):''), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); $db->commit(); @@ -120,10 +120,10 @@ if ($action == "save" && empty($cancel)) * View */ -$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); print ''; @@ -131,23 +131,23 @@ print ''; print ''; $param = ''; -$param.= '&search_event='.urlencode($search_event); +$param .= '&search_event='.urlencode($search_event); -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); print ''.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'
'; print "
\n"; -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 ''; print ''; // Action column print ''; print ''; @@ -155,10 +155,10 @@ print ''."\n"; print ''; print ''; -print ''; +print ''; print ''."\n"; // Show each trigger (list is in c_action_trigger) -if (! empty($triggers)) +if (!empty($triggers)) { foreach ($triggers as $trigger) { @@ -170,7 +170,7 @@ if (! empty($triggers)) if ($module == 'proposal_supplier') $module = 'supplier_proposal'; //print 'module='.$module.'
'; - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; @@ -182,9 +182,9 @@ if (! empty($triggers)) print ''; print ''; print ''."\n"; } } diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index c0150ce5111..0dc682a32f8 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -25,20 +25,20 @@ * \brief Page to setup the bank module */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","companies","bills","other","banks")); +$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); -$actionsave=GETPOST('save', 'alpha'); +$actionsave = GETPOST('save', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); @@ -53,7 +53,7 @@ $type = 'bankaccount'; if ($action == 'setbankorder') { if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -65,7 +65,7 @@ if ($action == 'setbankorder') { if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -75,7 +75,7 @@ if ($action == 'setreportlastnumreleve') { elseif ($action == 'unsetreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -87,7 +87,7 @@ elseif ($action == 'unsetreportlastnumreleve') { if ($action == 'setbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -97,7 +97,7 @@ if ($action == 'setbankcolorizemovement') { elseif ($action == 'unsetbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -109,21 +109,21 @@ if ($actionsave) { $db->begin(); - $i=1; $errorsaved=0; - $error=0; + $i = 1; $errorsaved = 0; + $error = 0; // Save colors while ($i <= 2) { - $color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); - if ($color=='-1') $color=''; + $color = trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha')); + if ($color == '-1') $color = ''; - $res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; $i++; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -153,10 +153,10 @@ if ($action == 'specimen') { $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; - $classname = "pdf_" . $modele; + $classname = "pdf_".$modele; break; } } @@ -167,7 +167,7 @@ if ($action == 'specimen') { $module = new $classname($db); if ($module->write_file($object, $langs) > 0) { - header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } else { @@ -214,13 +214,13 @@ elseif ($action == 'setdoc') { */ $form = new Form($db); -$formother=new FormOther($db); +$formother = new FormOther($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("BankSetupModule")); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup'); print ''; @@ -235,10 +235,10 @@ print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("ActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").''.$langs->trans("All").'/'.$langs->trans("None").'
'.$trigger['code'].''.$trigger['label'].''; - $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; - $value=$conf->global->$key; - print ''; + $key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; + $value = $conf->global->$key; + print ''; print '
'; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; print "\n"; @@ -254,7 +254,7 @@ $i = 0; $nbofbank = count($bankorder); while ($i < $nbofbank) { print ''; - print ''; print ''; } else { - print ''; } print ''; - print '' . "\n"; + print ''."\n"; $i++; } -print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Status") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").' 
' . $bankorder[$i][0] . "\n"; + print ''.$bankorder[$i][0]."\n"; print $bankorder[$i][1]; print ''; @@ -272,16 +272,16 @@ while ($i < $nbofbank) { print ''; + print ''; print img_picto($langs->trans("Disabled"), 'off'); print ' 
' . "\n"; +print '
'."\n"; print '

'; @@ -296,9 +296,9 @@ print load_fiche_titre($langs->trans("BankAccountModelModule"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql .= " FROM " . MAIN_DB_PREFIX . "document_model"; -$sql .= " WHERE type = '" . $type . "'"; -$sql .= " AND entity = " . $conf->entity; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $i = 0; @@ -315,19 +315,19 @@ else { print "\n"; print "\n"; -print ''; -print ''; -print '\n"; -print '\n"; -print ''; -print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { - $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); + $dir = dol_buildpath($reldir."core/modules/bank".$valdir); if (is_dir($dir)) { $handle = opendir($dir); @@ -340,11 +340,11 @@ foreach ($dirmodels as $reldir) { foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - if (file_exists($dir . '/' . $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir . '/' . $file; + require_once $dir.'/'.$file; $module = new $classname($db); $modulequalified = 1; @@ -365,15 +365,15 @@ foreach ($dirmodels as $reldir) { // Active if (in_array($name, $def)) { - print ''; } else { - print '"; } @@ -383,21 +383,21 @@ foreach ($dirmodels as $reldir) { print img_picto($langs->trans("Default"), 'on'); } else { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; // Info - $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; - $htmltooltip .= '
' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip .= '
' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip .= '

' . $langs->trans("FeaturesSupported") . ':'; - $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); @@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) { // Preview print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "' . $langs->trans("Default") . "' . $langs->trans("ShortInfo") . '' . $langs->trans("Preview") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; if ($module->type == 'pdf') { - print '' . img_object($langs->trans("Preview"), 'bill') . ''; + print ''.img_object($langs->trans("Preview"), 'bill').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -433,7 +433,7 @@ print '

'; print load_fiche_titre($langs->trans("BankColorizeMovement"), '', ''); print ''; print "\n"; -print ''; +print ''; print ''."\n"; print "\n"; @@ -442,28 +442,28 @@ print $langs->trans('BankColorizeMovementDesc'); print ""; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { - print ''; } else { - print '"; } print "\n"; -if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) +if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) { - $i=1; + $i = 1; while ($i <= 2) { - $key=$i; - $color='BANK_COLORIZE_MOVEMENT_COLOR'.$key; + $key = $i; + $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; print ''; @@ -471,7 +471,7 @@ if(! empty($conf->global->BANK_COLORIZE_MOVEMENT)) print '"; // Color print ''; print ""; $i++; @@ -491,9 +491,9 @@ print load_fiche_titre($langs->trans("Other"), '', ''); print "
' . $langs->trans("Name") . ''.$langs->trans("Name").''.$langs->trans("Value").'
' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "
'.$langs->trans("BankColorizeMovementName".$key)."'; - print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); + print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset'); print '
\n"; print "\n"; -print ''; -print ''; -print '\n"; +print ''; +print ''; +print '\n"; print "\n"; print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { - print ''; } else { - print '"; } diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index a531a9c870c..80bb04f4852 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","other","agenda")); +$langs->loadLangs(array("admin", "other", "agenda")); if (!$user->admin) accessforbidden(); @@ -37,7 +37,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( +$arrayofparameters = array( 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), @@ -60,14 +60,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; llxHeader('', $langs->trans("DAVSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup'); print ''; print ''; -$head=dav_admin_prepare_head(); +$head = dav_admin_prepare_head(); dol_fiche_head($head, 'webdav', '', -1, 'action'); @@ -80,7 +80,7 @@ if ($action == 'edit') print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."
'; @@ -503,16 +503,16 @@ print $langs->trans('AutoReportLastAccountStatement'); print '' . "\n"; - print ''; + print ''."\n"; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''."\n"; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "
'; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) continue; @@ -100,7 +100,7 @@ if ($action == 'edit') } else { - print ''; + print ''; } print ''; } @@ -119,7 +119,7 @@ else print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; print "\n"; // Load array of available notifications -$notificationtrigger=new InterfaceNotification($db); -$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); +$notificationtrigger = new InterfaceNotification($db); +$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); -foreach($listofnotifiedevents as $notifiedevent) +foreach ($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); // Special cases @@ -226,35 +226,35 @@ foreach($listofnotifiedevents as $notifiedevent) print ''; print ''; print ''; // Show prof id in address into pdf -for($i=1; $i<=6; $i++) +for ($i = 1; $i <= 6; $i++) { - if (! $noCountryCode) + if (!$noCountryCode) { - $pid=$langs->transcountry("ProfId".$i, $mysoc->country_code); - if ($pid == '-') $pid=false; + $pid = $langs->transcountry("ProfId".$i, $mysoc->country_code); + if ($pid == '-') $pid = false; } else { @@ -194,7 +194,7 @@ for($i=1; $i<=6; $i++) { print ''; } } @@ -207,32 +207,32 @@ print '
'; // Localtaxes -$locales =''; -$text=''; +$locales = ''; +$text = ''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1", $mysoc->country_code); - $text =''; } if ($mysoc->useLocalTax(2)) { - $locales.=($locales?' & ':'').$langs->transcountry("LT2", $mysoc->country_code); + $locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code); - $text.= ''; + $text .= ''; } } $title = $langs->trans("PDFRulesForSalesTax"); if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $title.=' - '.$langs->trans("PDFLocaltax", $locales); + $title .= ' - '.$langs->trans("PDFLocaltax", $locales); } print load_fiche_titre($title, '', ''); @@ -243,7 +243,7 @@ print ''; // Locataxes @@ -263,31 +263,31 @@ print ''; //Ref print ''; //Details print ''; //Invert sender and recipient print ''; // Place customer adress to the ISO location print ''; @@ -317,9 +317,9 @@ print "\n"; print ''."\n"; print ''."\n"; print ''; foreach ($arrayhandler as $key => $module) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -265,9 +265,9 @@ foreach ($arrayhandler as $key => $module) // Show example of numbering module print ''."\n"; @@ -288,7 +288,7 @@ print ''; //if($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK == 1) // Patter for Password Perso -if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ +if ($conf->global->USER_PASSWORD_GENERATED == "Perso") { $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); print '
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); @@ -166,22 +166,22 @@ print "
"; // 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 // Show message -$message=''; -$url=''.$urlwithroot.'/dav/fileserver.php'; -$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url); -$message.='
'; -if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) +$message = ''; +$url = ''.$urlwithroot.'/dav/fileserver.php'; +$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url); +$message .= '
'; +if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { - $urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:''); - $url=''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; - $message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); - $message.='
'; + $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); + $url = ''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; + $message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); + $message .= '
'; } print $message; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index f4922a33bbb..ae383242b11 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -36,12 +36,12 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'error if (!$user->admin) accessforbidden(); -$id=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'alpha'); +$id = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'alpha'); -$mode = GETPOST('mode', 'aZ09')?GETPOST('mode', 'aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' +$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus' -$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'); @@ -49,32 +49,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='page,param'; -if (! $sortorder) $sortorder='ASC'; +if (!$sortfield) $sortfield = 'page,param'; +if (!$sortorder) $sortorder = 'ASC'; $defaulturl = GETPOST('defaulturl'); $defaultkey = GETPOST('defaultkey', 'alpha'); $defaultvalue = GETPOST('defaultvalue'); -$defaulturl=preg_replace('/^\//', '', $defaulturl); +$defaulturl = preg_replace('/^\//', '', $defaulturl); $urlpage = GETPOST('urlpage'); $key = GETPOST('key'); $value = GETPOST('value'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admindefaultvalues','globaladmin')); +$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); /* * 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'; @@ -82,11 +82,11 @@ 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 { - $defaulturl=''; - $defaultkey=''; - $defaultvalue=''; - $toselect=''; - $search_array_options=array(); + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; + $toselect = ''; + $search_array_options = array(); } if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') @@ -97,7 +97,7 @@ if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { - $error=0; + $error = 0; if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { @@ -126,7 +126,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac } } - if (! $error) + if (!$error) { $db->begin(); @@ -137,7 +137,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac if (GETPOST('actionmodify')) { $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; - $sql.= " WHERE rowid = ".$id; + $sql .= " WHERE rowid = ".$id; } $result = $db->query($sql); @@ -145,16 +145,16 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action=""; - $defaulturl=''; - $defaultkey=''; - $defaultvalue=''; + $action = ""; + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; } else { $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); - $action=''; + $action = ''; } } } @@ -181,28 +181,28 @@ if ($action == 'delete') * View */ -$form=new Form($db); +$form = new Form($db); $formadmin = new FormAdmin($db); -$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; +$wikihelp = 'EN:Setup|FR:Paramétrage|ES:Configuración'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$param='&mode='.$mode; +$param = '&mode='.$mode; -$enabledisablehtml.= $langs->trans("EnableDefaultValues").' '; +$enabledisablehtml .= $langs->trans("EnableDefaultValues").' '; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable - $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml.= ''; - $enabledisablehtml.= img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup'); @@ -210,15 +210,15 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl print ''.$langs->trans("DefaultValuesDesc")."
\n"; print "
\n"; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; -if ($defaulturl) $param.='&defaulturl='.urlencode($defaulturl); -if ($defaultkey) $param.='&defaultkey='.urlencode($defaultkey); -if ($defaultvalue) $param.='&defaultvalue='.urlencode($defaultvalue); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); +if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); +if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); -print 'entity) && $debug)?'?debug=1':'').'" method="POST">'; +print 'entity) && $debug) ? '?debug=1' : '').'" method="POST">'; if ($optioncss != '') print ''; print ''; print ''; @@ -227,7 +227,7 @@ print ''; print ''; print ''; -$head=defaultvalues_prepare_head(); +$head = defaultvalues_prepare_head(); dol_fiche_head($head, $mode, '', -1, ''); @@ -248,22 +248,22 @@ print '
'; print ''; print ''; // Page -$texthelp=$langs->trans("PageUrlForDefaultValues"); -if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); -else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); -$texthelp.='

'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); -$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); +$texthelp = $langs->trans("PageUrlForDefaultValues"); +if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); +else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); +$texthelp .= '

'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); +$texturl = $form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); // Field -$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); +$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') { - $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); + $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); } else { - $texthelp='field or alias.field'; - $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); + $texthelp = 'field or alias.field'; + $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); } print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); // Value @@ -271,24 +271,24 @@ if ($mode != 'focus' && $mode != 'mandatory') { if ($mode != 'sortorder') { - $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST + $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST unset($substitutionarray['__USER_SIGNATURE__']); - $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - foreach($substitutionarray as $key => $val) + $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; + foreach ($substitutionarray as $key => $val) { - $texthelp.=$key.' -> '.$val.'
'; + $texthelp .= $key.' -> '.$val.'
'; } - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); + $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); } else { - $texthelp='ASC or DESC'; - $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); + $texthelp = 'ASC or DESC'; + $textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp); } print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); } // Entity -if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); +if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); // Actions print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); @@ -315,10 +315,10 @@ if ($mode != 'focus' && $mode != 'mandatory') print ''; } // Limit to superadmin -if (! empty($conf->multicompany->enabled) && !$user->entity) +if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; } else @@ -328,8 +328,8 @@ else print ''; } print '\n"; print ''; @@ -337,10 +337,10 @@ print ''; // Show constants $sql = "SELECT rowid, entity, type, page, param, value"; -$sql.= " FROM ".MAIN_DB_PREFIX."default_values"; -$sql.= " WHERE type = '".$db->escape($mode)."'"; -$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= " FROM ".MAIN_DB_PREFIX."default_values"; +$sql .= " WHERE type = '".$db->escape($mode)."'"; +$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")"; +$sql .= $db->order($sortfield, $sortorder); dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); @@ -389,15 +389,15 @@ if ($result) print ''; - $filterfound=0; + $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($fieldlist[$field] == 'entity') continue; - $showfield=1; // By default + $showfield = 1; // By default - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } if ($showfield) { @@ -1283,7 +1283,7 @@ if ($id) print ''; @@ -1297,84 +1297,84 @@ if ($id) // Determines the name of the field in relation to the possible names // in data dictionaries - $showfield=1; // By defaut - $align="left"; - $cssprefix=''; - $sortable=1; - $valuetoshow=ucfirst($fieldlist[$field]); // By defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate + $showfield = 1; // By defaut + $align = "left"; + $cssprefix = ''; + $sortable = 1; + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate // Special cases - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='center'; + if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); } + if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate"); + else $valuetoshow = $langs->trans("Amount"); + $align = 'center'; } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='position') { $align='right'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments"); } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } - if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); } - if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); } - if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); } - if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); } - if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); } - if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); } - if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); } - if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } - if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } - if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } - if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("WithCounter"); } - if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } - if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); } - if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); } - if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } - if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } - if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } - if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); } + if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } + if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } + if ($fieldlist[$field] == 'position') { $align = 'right'; } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } + if ($fieldlist[$field] == 'libelle_facture') { $valuetoshow = $langs->trans("LabelOnDocuments"); } + if ($fieldlist[$field] == 'country') { $valuetoshow = $langs->trans("Country"); } + if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $align = "center"; } + if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); } + if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $align = "center"; } + if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); } + if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); } + if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); } + if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); } + if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); } + if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); $sortable = 0; } + if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); $sortable = 0; } + if ($fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); } + if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountsparent"); } + if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); } + if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); } + if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); } + if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); } + if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); } + if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); } + if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); } + if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); } + if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); } + if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); } + if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); } + if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); } + if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); } + if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); } + if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); } + if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); } + if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); } + if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); } + if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); } + if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); } + if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); } + if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); } + if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); } + if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); } + if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } + if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } // Show field title if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix); } } // Favorite - Only activated on country dictionary - if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -1387,12 +1387,12 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); print ''; - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { - $tmpaction='edit'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; // Show fields if (empty($reshook)) { @@ -1400,10 +1400,10 @@ if ($id) } print ''; } @@ -1635,34 +1635,34 @@ if ($id) // Can an entry be erased or disabled ? // all true by default - $iserasable=1; - $canbedisabled=1; - $canbemodified=1; + $iserasable = 1; + $canbedisabled = 1; + $canbemodified = 1; if (isset($obj->code) && $id != 10) { if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } elseif ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; } - elseif ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } + elseif ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; } } if ($id == 25 && in_array($obj->code, array('banner', 'blogpost', 'other', 'page'))) { $iserasable = 0; $canbedisabled = 0; if (in_array($obj->code, array('banner'))) $canbedisabled = 1; } - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } - $canbemodified=$iserasable; - if ($obj->code == 'RECEP') $canbemodified=1; - if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified=1; + if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable = 0; } + if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled = 0; $canbedisabled = 0; } + $canbemodified = $iserasable; + if ($obj->code == 'RECEP') $canbemodified = 1; + if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified = 1; // Build Url. The table is id=, the id of line is rowid= - $rowidcol=$tabrowid[$id]; + $rowidcol = $tabrowid[$id]; // If rowidcol not defined - if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27,32))) $rowidcol='rowid'; - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((! empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0')?$obj->{$rowidcol}:(! empty($obj->code)?urlencode($obj->code):'')).'&code='.(! empty($obj->code)?urlencode($obj->code):''); - if (! empty($param)) $url .= '&'.$param; - if (! is_null($withentity)) $url .= '&entity='.$withentity; - $url.='&'; + if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) $rowidcol = 'rowid'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((!empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0') ? $obj->{$rowidcol}:(!empty($obj->code) ?urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if (!empty($param)) $url .= '&'.$param; + if (!is_null($withentity)) $url .= '&entity='.$withentity; + $url .= '&'; // Favorite // Only activated on country dictionary @@ -1679,9 +1679,9 @@ if ($id) if ($canbedisabled) print ''.$actl[$obj->active].''; else { - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); + if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) print $langs->trans("AlwaysActive"); elseif (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated"); - elseif (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); + elseif (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption"); else print $langs->trans("AlwaysActive"); } print ""; @@ -1721,7 +1721,7 @@ else * Show list of dictionary to show */ - $lastlineisempty=false; + $lastlineisempty = false; print '
'; print '
'; - print ''; // We see environment, but to change it we must switch on other entity + print ''; // We see environment, but to change it we must switch on other entity print ''; -$disabled=''; -if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"'; +$disabled = ''; +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"'; print ''; print "
'; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; - print ''.img_delete().''; + print ''.img_delete().''; } else { print ''; print ''; - print '
'; + print '
'; print ''; print ''; } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 23a9aa4b3b1..ec494d5a812 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -$modules=array( +$modules = array( 'agenda' => array( array( 'code' => 'MAIN_DELAY_ACTIONS_TODO', @@ -137,11 +137,11 @@ $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs-> if ($action == 'update') { - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { if (GETPOST($delay['code']) != '') { @@ -155,11 +155,11 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); // For update value with percentage - $plus=''; - if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; + $plus = ''; + if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values - for($i=0; $i<4; $i++) { - if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); + for ($i = 0; $i < 4; $i++) { + if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); } } @@ -178,7 +178,7 @@ print ''.$langs->transnoentities("DelaysOfToleranceD print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."
\n"; print "
\n"; -$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($action == 'edit') { @@ -189,13 +189,13 @@ if ($action == 'edit') print ''; print ''; - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print ''; print ''; print ''; print ''; print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; @@ -214,7 +214,7 @@ if ($action == 'edit') print '
'.$langs->trans("MAIN_DISABLE_METEO").''; - print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO)); + print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); print '
'; @@ -228,13 +228,13 @@ else print ''; print ''; - foreach($modules as $module => $delays) + foreach ($modules as $module => $delays) { - if (! empty($conf->$module->enabled)) + if (!empty($conf->$module->enabled)) { - foreach($delays as $delay) + foreach ($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print ''; print ''; print ''; @@ -264,30 +264,30 @@ print '
'; // Show logo for weather print ''.$langs->trans("DescWeather").' '; -if($action == 'edit') { +if ($action == 'edit') { $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); - if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; else $str_mode_enabled = $str_mode_percentage; print ''.$str_mode_enabled.''; print ''; print '

'; } else { - if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); else print $langs->trans('MeteoPercentageModEnabled'); print '

'; } -$offset=0; -$cursor=10; // By default +$offset = 0; +$cursor = 10; // By default //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; -$level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; -$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; -$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; -$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; -$text=''; $options='class="valignmiddle" height="60px"'; +$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; +$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; +$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; +$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; +$text = ''; $options = 'class="valignmiddle" height="60px"'; if ($action == 'edit') { @@ -361,7 +361,7 @@ if ($action == 'edit') { global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { print '
'; print '
'; print img_weather($text, 0, $options); @@ -404,7 +404,7 @@ if ($action == 'edit') { print '
'; -if($action == 'edit') { +if ($action == 'edit') { print '
'; print '
'; } else { diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 8254c5931b8..bc0f57d40fb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -43,35 +43,35 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","main","companies","resource","holiday","accountancy","hrm","orders","contracts","projects","propal","bills","interventions")); +$langs->loadLangs(array("errors", "admin", "main", "companies", "resource", "holiday", "accountancy", "hrm", "orders", "contracts", "projects", "propal", "bills", "interventions")); -$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; -$confirm=GETPOST('confirm', 'alpha'); -$id=GETPOST('id', 'int'); -$rowid=GETPOST('rowid', 'alpha'); -$entity=GETPOST('entity', 'int'); -$code=GETPOST('code', 'alpha'); +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'alpha'); +$entity = GETPOST('entity', 'int'); +$code = GETPOST('code', 'alpha'); -$allowed=$user->admin; -if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account -if ($id == 10 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Vat page allowed to manager of chart account -if ($id == 17 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with type of expense report and accounting account allowed to manager of chart account -if (! $allowed) accessforbidden(); +$allowed = $user->admin; +if ($id == 7 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Tax page allowed to manager of chart account +if ($id == 10 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Vat page allowed to manager of chart account +if ($id == 17 && !empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with type of expense report and accounting account allowed to manager of chart account +if (!$allowed) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); -$listoffset=GETPOST('listoffset'); -$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; // To avoid too long dictionaries +$listoffset = GETPOST('listoffset'); +$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries $active = 1; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $listlimit * $page ; +$offset = $listlimit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -89,10 +89,10 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,38,0,5,11,0,32,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,37,0,25,0); +$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 27, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 0, 15, 30, 0, 37, 0, 25, 0); // Name of SQL tables of dictionaries -$tabname=array(); +$tabname = array(); $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique"; $tabname[2] = MAIN_DB_PREFIX."c_departements"; $tabname[3] = MAIN_DB_PREFIX."c_regions"; @@ -102,39 +102,39 @@ $tabname[6] = MAIN_DB_PREFIX."c_actioncomm"; $tabname[7] = MAIN_DB_PREFIX."c_chargesociales"; $tabname[8] = MAIN_DB_PREFIX."c_typent"; $tabname[9] = MAIN_DB_PREFIX."c_currencies"; -$tabname[10]= MAIN_DB_PREFIX."c_tva"; -$tabname[11]= MAIN_DB_PREFIX."c_type_contact"; -$tabname[12]= MAIN_DB_PREFIX."c_payment_term"; -$tabname[13]= MAIN_DB_PREFIX."c_paiement"; -$tabname[14]= MAIN_DB_PREFIX."c_ecotaxe"; -$tabname[15]= MAIN_DB_PREFIX."c_paper_format"; -$tabname[16]= MAIN_DB_PREFIX."c_prospectlevel"; -$tabname[17]= MAIN_DB_PREFIX."c_type_fees"; -$tabname[18]= MAIN_DB_PREFIX."c_shipment_mode"; -$tabname[19]= MAIN_DB_PREFIX."c_effectif"; -$tabname[20]= MAIN_DB_PREFIX."c_input_method"; -$tabname[21]= MAIN_DB_PREFIX."c_availability"; -$tabname[22]= MAIN_DB_PREFIX."c_input_reason"; -$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; -$tabname[24]= MAIN_DB_PREFIX."c_type_resource"; -$tabname[25]= MAIN_DB_PREFIX."c_type_container"; +$tabname[10] = MAIN_DB_PREFIX."c_tva"; +$tabname[11] = MAIN_DB_PREFIX."c_type_contact"; +$tabname[12] = MAIN_DB_PREFIX."c_payment_term"; +$tabname[13] = MAIN_DB_PREFIX."c_paiement"; +$tabname[14] = MAIN_DB_PREFIX."c_ecotaxe"; +$tabname[15] = MAIN_DB_PREFIX."c_paper_format"; +$tabname[16] = MAIN_DB_PREFIX."c_prospectlevel"; +$tabname[17] = MAIN_DB_PREFIX."c_type_fees"; +$tabname[18] = MAIN_DB_PREFIX."c_shipment_mode"; +$tabname[19] = MAIN_DB_PREFIX."c_effectif"; +$tabname[20] = MAIN_DB_PREFIX."c_input_method"; +$tabname[21] = MAIN_DB_PREFIX."c_availability"; +$tabname[22] = MAIN_DB_PREFIX."c_input_reason"; +$tabname[23] = MAIN_DB_PREFIX."c_revenuestamp"; +$tabname[24] = MAIN_DB_PREFIX."c_type_resource"; +$tabname[25] = MAIN_DB_PREFIX."c_type_container"; //$tabname[26]= MAIN_DB_PREFIX."c_units"; -$tabname[27]= MAIN_DB_PREFIX."c_stcomm"; -$tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; -$tabname[29]= MAIN_DB_PREFIX."c_lead_status"; -$tabname[30]= MAIN_DB_PREFIX."c_format_cards"; +$tabname[27] = MAIN_DB_PREFIX."c_stcomm"; +$tabname[28] = MAIN_DB_PREFIX."c_holiday_types"; +$tabname[29] = MAIN_DB_PREFIX."c_lead_status"; +$tabname[30] = MAIN_DB_PREFIX."c_format_cards"; //$tabname[31]= MAIN_DB_PREFIX."accounting_system"; -$tabname[32]= MAIN_DB_PREFIX."c_hrm_public_holiday"; -$tabname[33]= MAIN_DB_PREFIX."c_hrm_department"; -$tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; +$tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday"; +$tabname[33] = MAIN_DB_PREFIX."c_hrm_department"; +$tabname[34] = MAIN_DB_PREFIX."c_hrm_function"; -$tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat"; -$tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range"; -$tabname[37]= MAIN_DB_PREFIX."c_units"; -$tabname[38]= MAIN_DB_PREFIX."c_socialnetworks"; +$tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat"; +$tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range"; +$tabname[37] = MAIN_DB_PREFIX."c_units"; +$tabname[38] = MAIN_DB_PREFIX."c_socialnetworks"; // Dictionary labels -$tablib=array(); +$tablib = array(); $tablib[1] = "DictionaryCompanyJuridicalType"; $tablib[2] = "DictionaryCanton"; $tablib[3] = "DictionaryRegion"; @@ -144,38 +144,38 @@ $tablib[6] = "DictionaryActions"; $tablib[7] = "DictionarySocialContributions"; $tablib[8] = "DictionaryCompanyType"; $tablib[9] = "DictionaryCurrency"; -$tablib[10]= "DictionaryVAT"; -$tablib[11]= "DictionaryTypeContact"; -$tablib[12]= "DictionaryPaymentConditions"; -$tablib[13]= "DictionaryPaymentModes"; -$tablib[14]= "DictionaryEcotaxe"; -$tablib[15]= "DictionaryPaperFormat"; -$tablib[16]= "DictionaryProspectLevel"; -$tablib[17]= "DictionaryFees"; -$tablib[18]= "DictionarySendingMethods"; -$tablib[19]= "DictionaryStaff"; -$tablib[20]= "DictionaryOrderMethods"; -$tablib[21]= "DictionaryAvailability"; -$tablib[22]= "DictionarySource"; -$tablib[23]= "DictionaryRevenueStamp"; -$tablib[24]= "DictionaryResourceType"; -$tablib[25]= "DictionaryTypeOfContainer"; +$tablib[10] = "DictionaryVAT"; +$tablib[11] = "DictionaryTypeContact"; +$tablib[12] = "DictionaryPaymentConditions"; +$tablib[13] = "DictionaryPaymentModes"; +$tablib[14] = "DictionaryEcotaxe"; +$tablib[15] = "DictionaryPaperFormat"; +$tablib[16] = "DictionaryProspectLevel"; +$tablib[17] = "DictionaryFees"; +$tablib[18] = "DictionarySendingMethods"; +$tablib[19] = "DictionaryStaff"; +$tablib[20] = "DictionaryOrderMethods"; +$tablib[21] = "DictionaryAvailability"; +$tablib[22] = "DictionarySource"; +$tablib[23] = "DictionaryRevenueStamp"; +$tablib[24] = "DictionaryResourceType"; +$tablib[25] = "DictionaryTypeOfContainer"; //$tablib[26]= "DictionaryUnits"; -$tablib[27]= "DictionaryProspectStatus"; -$tablib[28]= "DictionaryHolidayTypes"; -$tablib[29]= "DictionaryOpportunityStatus"; -$tablib[30]= "DictionaryFormatCards"; +$tablib[27] = "DictionaryProspectStatus"; +$tablib[28] = "DictionaryHolidayTypes"; +$tablib[29] = "DictionaryOpportunityStatus"; +$tablib[30] = "DictionaryFormatCards"; //$tablib[31]= "DictionaryAccountancysystem"; -$tablib[32]= "DictionaryPublicHolidays"; -$tablib[33]= "DictionaryDepartment"; -$tablib[34]= "DictionaryFunction"; -$tablib[35]= "DictionaryExpenseTaxCat"; -$tablib[36]= "DictionaryExpenseTaxRange"; -$tablib[37]= "DictionaryMeasuringUnits"; -$tablib[38]= "DictionarySocialNetworks"; +$tablib[32] = "DictionaryPublicHolidays"; +$tablib[33] = "DictionaryDepartment"; +$tablib[34] = "DictionaryFunction"; +$tablib[35] = "DictionaryExpenseTaxCat"; +$tablib[36] = "DictionaryExpenseTaxRange"; +$tablib[37] = "DictionaryMeasuringUnits"; +$tablib[38] = "DictionarySocialNetworks"; // Requests to extract data -$tabsql=array(); +$tabsql = array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; @@ -185,161 +185,161 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; -$tabsql[10]= "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; -$tabsql[11]= "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; -$tabsql[12]= "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = " . getEntity($tabname[12]); -$tabsql[13]= "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = " . getEntity($tabname[13]); -$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; -$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; -$tabsql[16]= "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; -$tabsql[17]= "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees"; -$tabsql[18]= "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; -$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; -$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; -$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; -$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; -$tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; -$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; +$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[11] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; +$tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = ".getEntity($tabname[12]); +$tabsql[13] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = ".getEntity($tabname[13]); +$tabsql[14] = "SELECT e.rowid as rowid, e.code as code, e.label, e.price, e.organization, e.fk_pays as country_id, c.code as country_code, c.label as country, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_country as c WHERE e.fk_pays=c.rowid and c.active=1"; +$tabsql[15] = "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format"; +$tabsql[16] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectlevel"; +$tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FROM ".MAIN_DB_PREFIX."c_type_fees"; +$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; +$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; +$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; +$tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; +$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; +$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; +$tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; -$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; -$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; -$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; +$tabsql[27] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; +$tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; -$tabsql[32]= "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1"; -$tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; -$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; -$tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; -$tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; -$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; -$tabsql[38]= "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$tabsql[32] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1"; +$tabsql[33] = "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; +$tabsql[34] = "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; +$tabsql[35] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; +$tabsql[36] = "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; +$tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; +$tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; // Criteria to sort dictionaries -$tabsqlsort=array(); -$tabsqlsort[1] ="country ASC, code ASC"; -$tabsqlsort[2] ="country ASC, code ASC"; -$tabsqlsort[3] ="country ASC, code ASC"; -$tabsqlsort[4] ="code ASC"; -$tabsqlsort[5] ="label ASC"; -$tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC"; -$tabsqlsort[7] ="country ASC, code ASC, a.libelle ASC"; -$tabsqlsort[8] ="country DESC,".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?' t.position ASC,':'')." libelle ASC"; -$tabsqlsort[9] ="label ASC"; -$tabsqlsort[10]="country ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC"; -$tabsqlsort[11]="t.element ASC, t.source ASC, t.position ASC, t.code ASC"; -$tabsqlsort[12]="sortorder ASC, code ASC"; -$tabsqlsort[13]="code ASC"; -$tabsqlsort[14]="country ASC, e.organization ASC, code ASC"; -$tabsqlsort[15]="rowid ASC"; -$tabsqlsort[16]="sortorder ASC"; -$tabsqlsort[17]="code ASC"; -$tabsqlsort[18]="code ASC, libelle ASC"; -$tabsqlsort[19]="id ASC"; -$tabsqlsort[20]="code ASC, libelle ASC"; -$tabsqlsort[21]="code ASC, label ASC"; -$tabsqlsort[22]="code ASC, label ASC"; -$tabsqlsort[23]="country ASC, taux ASC"; -$tabsqlsort[24]="code ASC, label ASC"; -$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC"; +$tabsqlsort = array(); +$tabsqlsort[1] = "country ASC, code ASC"; +$tabsqlsort[2] = "country ASC, code ASC"; +$tabsqlsort[3] = "country ASC, code ASC"; +$tabsqlsort[4] = "code ASC"; +$tabsqlsort[5] = "label ASC"; +$tabsqlsort[6] = "a.type ASC, a.module ASC, a.position ASC, a.code ASC"; +$tabsqlsort[7] = "country ASC, code ASC, a.libelle ASC"; +$tabsqlsort[8] = "country DESC,".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ' t.position ASC,' : '')." libelle ASC"; +$tabsqlsort[9] = "label ASC"; +$tabsqlsort[10] = "country ASC, code ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC"; +$tabsqlsort[11] = "t.element ASC, t.source ASC, t.position ASC, t.code ASC"; +$tabsqlsort[12] = "sortorder ASC, code ASC"; +$tabsqlsort[13] = "code ASC"; +$tabsqlsort[14] = "country ASC, e.organization ASC, code ASC"; +$tabsqlsort[15] = "rowid ASC"; +$tabsqlsort[16] = "sortorder ASC"; +$tabsqlsort[17] = "code ASC"; +$tabsqlsort[18] = "code ASC, libelle ASC"; +$tabsqlsort[19] = "id ASC"; +$tabsqlsort[20] = "code ASC, libelle ASC"; +$tabsqlsort[21] = "code ASC, label ASC"; +$tabsqlsort[22] = "code ASC, label ASC"; +$tabsqlsort[23] = "country ASC, taux ASC"; +$tabsqlsort[24] = "code ASC, label ASC"; +$tabsqlsort[25] = "t.module ASC, t.code ASC, t.label ASC"; //$tabsqlsort[26]="code ASC"; -$tabsqlsort[27]="code ASC"; -$tabsqlsort[28]="country ASC, code ASC"; -$tabsqlsort[29]="position ASC"; -$tabsqlsort[30]="code ASC"; +$tabsqlsort[27] = "code ASC"; +$tabsqlsort[28] = "country ASC, code ASC"; +$tabsqlsort[29] = "position ASC"; +$tabsqlsort[30] = "code ASC"; //$tabsqlsort[31]="pcg_version ASC"; -$tabsqlsort[32]="country, year ASC, month ASC, day ASC"; -$tabsqlsort[33]="code ASC"; -$tabsqlsort[34]="code ASC"; -$tabsqlsort[35]="c.label ASC"; -$tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; -$tabsqlsort[37]="r.unit_type ASC, r.scale ASC, r.code ASC"; -$tabsqlsort[38]="rowid, code ASC"; +$tabsqlsort[32] = "country, year ASC, month ASC, day ASC"; +$tabsqlsort[33] = "code ASC"; +$tabsqlsort[34] = "code ASC"; +$tabsqlsort[35] = "c.label ASC"; +$tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; +$tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC"; +$tabsqlsort[38] = "rowid, code ASC"; // Field names in select result for dictionary display -$tabfield=array(); +$tabfield = array(); $tabfield[1] = "code,libelle,country"; -$tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country" +$tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,region,country_code-country" $tabfield[3] = "code,libelle,country_id,country"; $tabfield[4] = "code,label"; $tabfield[5] = "code,label"; $tabfield[6] = "code,libelle,type,color,position"; $tabfield[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfield[8] = "code,libelle,country_id,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfield[9] = "code,label,unicode"; -$tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfield[11]= "element,source,code,libelle,position"; -$tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; -$tabfield[13]= "code,libelle,type,entity"; -$tabfield[14]= "code,label,price,organization,country"; -$tabfield[15]= "code,libelle,width,height,unit"; -$tabfield[16]= "code,libelle,sortorder"; -$tabfield[17]= "code,label,accountancy_code"; -$tabfield[18]= "code,libelle,tracking"; -$tabfield[19]= "code,libelle"; -$tabfield[20]= "code,libelle"; -$tabfield[21]= "code,label"; -$tabfield[22]= "code,label"; -$tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfield[24]= "code,label"; -$tabfield[25]= "code,label"; +$tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[11] = "element,source,code,libelle,position"; +$tabfield[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfield[13] = "code,libelle,type,entity"; +$tabfield[14] = "code,label,price,organization,country"; +$tabfield[15] = "code,libelle,width,height,unit"; +$tabfield[16] = "code,libelle,sortorder"; +$tabfield[17] = "code,label,accountancy_code"; +$tabfield[18] = "code,libelle,tracking"; +$tabfield[19] = "code,libelle"; +$tabfield[20] = "code,libelle"; +$tabfield[21] = "code,label"; +$tabfield[22] = "code,label"; +$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfield[24] = "code,label"; +$tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; -$tabfield[27]= "code,libelle"; -$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; -$tabfield[29]= "code,label,percent,position"; -$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfield[27] = "code,libelle"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country"; +$tabfield[29] = "code,label,percent,position"; +$tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; -$tabfield[32]= "code,dayrule,year,month,day,country_id,country"; -$tabfield[33]= "code,label"; -$tabfield[34]= "code,label"; -$tabfield[35]= "label"; -$tabfield[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfield[37]= "code,label,short_label,unit_type,scale"; -$tabfield[38]= "code,label,url,icon,entity"; +$tabfield[32] = "code,dayrule,year,month,day,country_id,country"; +$tabfield[33] = "code,label"; +$tabfield[34] = "code,label"; +$tabfield[35] = "label"; +$tabfield[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfield[37] = "code,label,short_label,unit_type,scale"; +$tabfield[38] = "code,label,url,icon,entity"; // Edit field names for editing a record -$tabfieldvalue=array(); +$tabfieldvalue = array(); $tabfieldvalue[1] = "code,libelle,country"; -$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" +$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" $tabfieldvalue[3] = "code,libelle,country"; $tabfieldvalue[4] = "code,label"; $tabfieldvalue[5] = "code,label"; $tabfieldvalue[6] = "code,libelle,type,color,position"; $tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfieldvalue[8] = "code,libelle,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldvalue[9] = "code,label,unicode"; -$tabfieldvalue[10]= "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[11]= "element,source,code,libelle,position"; -$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; -$tabfieldvalue[13]= "code,libelle,type"; -$tabfieldvalue[14]= "code,label,price,organization,country"; -$tabfieldvalue[15]= "code,libelle,width,height,unit"; -$tabfieldvalue[16]= "code,libelle,sortorder"; -$tabfieldvalue[17]= "code,label,accountancy_code"; -$tabfieldvalue[18]= "code,libelle,tracking"; -$tabfieldvalue[19]= "code,libelle"; -$tabfieldvalue[20]= "code,libelle"; -$tabfieldvalue[21]= "code,label"; -$tabfieldvalue[22]= "code,label"; -$tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "code,label"; +$tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[11] = "element,source,code,libelle,position"; +$tabfieldvalue[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder"; +$tabfieldvalue[13] = "code,libelle,type"; +$tabfieldvalue[14] = "code,label,price,organization,country"; +$tabfieldvalue[15] = "code,libelle,width,height,unit"; +$tabfieldvalue[16] = "code,libelle,sortorder"; +$tabfieldvalue[17] = "code,label,accountancy_code"; +$tabfieldvalue[18] = "code,libelle,tracking"; +$tabfieldvalue[19] = "code,libelle"; +$tabfieldvalue[20] = "code,libelle"; +$tabfieldvalue[21] = "code,label"; +$tabfieldvalue[22] = "code,label"; +$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldvalue[24] = "code,label"; +$tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; -$tabfieldvalue[27]= "code,libelle"; -$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; -$tabfieldvalue[29]= "code,label,percent,position"; -$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfieldvalue[27] = "code,libelle"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country"; +$tabfieldvalue[29] = "code,label,percent,position"; +$tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; -$tabfieldvalue[32]= "code,dayrule,day,month,year,country"; -$tabfieldvalue[33]= "code,label"; -$tabfieldvalue[34]= "code,label"; -$tabfieldvalue[35]= "label"; -$tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfieldvalue[37]= "code,label,short_label,unit_type,scale"; -$tabfieldvalue[38]= "code,label,url,icon"; +$tabfieldvalue[32] = "code,dayrule,day,month,year,country"; +$tabfieldvalue[33] = "code,label"; +$tabfieldvalue[34] = "code,label"; +$tabfieldvalue[35] = "label"; +$tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfieldvalue[37] = "code,label,short_label,unit_type,scale"; +$tabfieldvalue[38] = "code,label,url,icon"; // Field names in the table for inserting a record -$tabfieldinsert=array(); +$tabfieldinsert = array(); $tabfieldinsert[1] = "code,libelle,fk_pays"; $tabfieldinsert[2] = "code_departement,nom,fk_region"; $tabfieldinsert[3] = "code_region,nom,fk_pays"; @@ -347,43 +347,43 @@ $tabfieldinsert[4] = "code,label"; $tabfieldinsert[5] = "code,label"; $tabfieldinsert[6] = "code,libelle,type,color,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible"; -$tabfieldinsert[8] = "code,libelle,fk_country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); +$tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : ''); $tabfieldinsert[9] = "code_iso,label,unicode"; -$tabfieldinsert[10]= "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldinsert[11]= "element,source,code,libelle,position"; -$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; -$tabfieldinsert[13]= "code,libelle,type,entity"; -$tabfieldinsert[14]= "code,label,price,organization,fk_pays"; -$tabfieldinsert[15]= "code,label,width,height,unit"; -$tabfieldinsert[16]= "code,label,sortorder"; -$tabfieldinsert[17]= "code,label,accountancy_code"; -$tabfieldinsert[18]= "code,libelle,tracking"; -$tabfieldinsert[19]= "code,libelle"; -$tabfieldinsert[20]= "code,libelle"; -$tabfieldinsert[21]= "code,label"; -$tabfieldinsert[22]= "code,label"; -$tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldinsert[24]= "code,label"; -$tabfieldinsert[25]= "code,label"; +$tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[11] = "element,source,code,libelle,position"; +$tabfieldinsert[12] = "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; +$tabfieldinsert[13] = "code,libelle,type,entity"; +$tabfieldinsert[14] = "code,label,price,organization,fk_pays"; +$tabfieldinsert[15] = "code,label,width,height,unit"; +$tabfieldinsert[16] = "code,label,sortorder"; +$tabfieldinsert[17] = "code,label,accountancy_code"; +$tabfieldinsert[18] = "code,libelle,tracking"; +$tabfieldinsert[19] = "code,libelle"; +$tabfieldinsert[20] = "code,libelle"; +$tabfieldinsert[21] = "code,label"; +$tabfieldinsert[22] = "code,label"; +$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; +$tabfieldinsert[24] = "code,label"; +$tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; -$tabfieldinsert[27]= "code,libelle"; -$tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; -$tabfieldinsert[29]= "code,label,percent,position"; -$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; +$tabfieldinsert[27] = "code,libelle"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country"; +$tabfieldinsert[29] = "code,label,percent,position"; +$tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; //$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; -$tabfieldinsert[32]= "code,dayrule,day,month,year,fk_country"; -$tabfieldinsert[33]= "code,label"; -$tabfieldinsert[34]= "code,label"; -$tabfieldinsert[35]= "label"; -$tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; -$tabfieldinsert[37]= "code,label,short_label,unit_type,scale"; -$tabfieldinsert[38]= "code,label,url,icon,entity"; +$tabfieldinsert[32] = "code,dayrule,day,month,year,fk_country"; +$tabfieldinsert[33] = "code,label"; +$tabfieldinsert[34] = "code,label"; +$tabfieldinsert[35] = "label"; +$tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat"; +$tabfieldinsert[37] = "code,label,short_label,unit_type,scale"; +$tabfieldinsert[38] = "code,label,url,icon,entity"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on // Use "nameoffield" if id field is not "rowid" or has not autoincrement on -$tabrowid=array(); +$tabrowid = array(); $tabrowid[1] = ""; $tabrowid[2] = ""; $tabrowid[3] = ""; @@ -393,79 +393,79 @@ $tabrowid[6] = "id"; $tabrowid[7] = "id"; $tabrowid[8] = "id"; $tabrowid[9] = "code_iso"; -$tabrowid[10]= ""; -$tabrowid[11]= "rowid"; -$tabrowid[12]= ""; -$tabrowid[13]= "id"; -$tabrowid[14]= ""; -$tabrowid[15]= ""; -$tabrowid[16]= "code"; -$tabrowid[17]= "id"; -$tabrowid[18]= "rowid"; -$tabrowid[19]= "id"; -$tabrowid[20]= ""; -$tabrowid[21]= "rowid"; -$tabrowid[22]= "rowid"; -$tabrowid[23]= ""; -$tabrowid[24]= ""; -$tabrowid[25]= ""; +$tabrowid[10] = ""; +$tabrowid[11] = "rowid"; +$tabrowid[12] = ""; +$tabrowid[13] = "id"; +$tabrowid[14] = ""; +$tabrowid[15] = ""; +$tabrowid[16] = "code"; +$tabrowid[17] = "id"; +$tabrowid[18] = "rowid"; +$tabrowid[19] = "id"; +$tabrowid[20] = ""; +$tabrowid[21] = "rowid"; +$tabrowid[22] = "rowid"; +$tabrowid[23] = ""; +$tabrowid[24] = ""; +$tabrowid[25] = ""; //$tabrowid[26]= ""; -$tabrowid[27]= "id"; -$tabrowid[28]= ""; -$tabrowid[29]= ""; -$tabrowid[30]= ""; +$tabrowid[27] = "id"; +$tabrowid[28] = ""; +$tabrowid[29] = ""; +$tabrowid[30] = ""; //$tabrowid[31]= ""; -$tabrowid[32]= "id"; -$tabrowid[33]= "rowid"; -$tabrowid[34]= "rowid"; -$tabrowid[35]= ""; -$tabrowid[36]= ""; -$tabrowid[37]= ""; -$tabrowid[38]= ""; +$tabrowid[32] = "id"; +$tabrowid[33] = "rowid"; +$tabrowid[34] = "rowid"; +$tabrowid[35] = ""; +$tabrowid[36] = ""; +$tabrowid[37] = ""; +$tabrowid[38] = ""; // Condition to show dictionary in setup page -$tabcond=array(); -$tabcond[1] = (! empty($conf->societe->enabled)); +$tabcond = array(); +$tabcond[1] = (!empty($conf->societe->enabled)); $tabcond[2] = true; $tabcond[3] = true; $tabcond[4] = true; -$tabcond[5] = (! empty($conf->societe->enabled) || ! empty($conf->adherent->enabled)); -$tabcond[6] = ! empty($conf->agenda->enabled); -$tabcond[7] = ! empty($conf->tax->enabled); -$tabcond[8] = ! empty($conf->societe->enabled); +$tabcond[5] = (!empty($conf->societe->enabled) || !empty($conf->adherent->enabled)); +$tabcond[6] = !empty($conf->agenda->enabled); +$tabcond[7] = !empty($conf->tax->enabled); +$tabcond[8] = !empty($conf->societe->enabled); $tabcond[9] = true; -$tabcond[10]= true; -$tabcond[11]= (! empty($conf->societe->enabled)); -$tabcond[12]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); -$tabcond[13]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)); -$tabcond[14]= (! empty($conf->product->enabled) && (! empty($conf->ecotax->enabled) || ! empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); -$tabcond[15]= true; -$tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); -$tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)); -$tabcond[18]= ! empty($conf->expedition->enabled) || ! empty($conf->reception->enabled); -$tabcond[19]= ! empty($conf->societe->enabled); -$tabcond[20]= ! empty($conf->fournisseur->enabled); -$tabcond[21]= ! empty($conf->propal->enabled); -$tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); -$tabcond[23]= true; -$tabcond[24]= ! empty($conf->resource->enabled); -$tabcond[25]= ! empty($conf->website->enabled); +$tabcond[10] = true; +$tabcond[11] = (!empty($conf->societe->enabled)); +$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); +$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)); +$tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY))); +$tabcond[15] = true; +$tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)); +$tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled)); +$tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled); +$tabcond[19] = !empty($conf->societe->enabled); +$tabcond[20] = !empty($conf->fournisseur->enabled); +$tabcond[21] = !empty($conf->propal->enabled); +$tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled)); +$tabcond[23] = true; +$tabcond[24] = !empty($conf->resource->enabled); +$tabcond[25] = !empty($conf->website->enabled); //$tabcond[26]= ! empty($conf->product->enabled); -$tabcond[27]= ! empty($conf->societe->enabled); -$tabcond[28]= ! empty($conf->holiday->enabled); -$tabcond[29]= ! empty($conf->projet->enabled); -$tabcond[30]= ! empty($conf->label->enabled); +$tabcond[27] = !empty($conf->societe->enabled); +$tabcond[28] = !empty($conf->holiday->enabled); +$tabcond[29] = !empty($conf->projet->enabled); +$tabcond[30] = !empty($conf->label->enabled); //$tabcond[31]= ! empty($conf->accounting->enabled); -$tabcond[32]= (! empty($conf->holiday->enabled) || ! empty($conf->hrm->enabled)); -$tabcond[33]= ! empty($conf->hrm->enabled); -$tabcond[34]= ! empty($conf->hrm->enabled); -$tabcond[35]= ! empty($conf->expensereport->enabled); -$tabcond[36]= ! empty($conf->expensereport->enabled); -$tabcond[37]= ! empty($conf->product->enabled); -$tabcond[38]= ! empty($conf->socialnetworks->enabled); +$tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); +$tabcond[33] = !empty($conf->hrm->enabled); +$tabcond[34] = !empty($conf->hrm->enabled); +$tabcond[35] = !empty($conf->expensereport->enabled); +$tabcond[36] = !empty($conf->expensereport->enabled); +$tabcond[37] = !empty($conf->product->enabled); +$tabcond[38] = !empty($conf->socialnetworks->enabled); // List of help for fields -$tabhelp=array(); +$tabhelp = array(); $tabhelp[1] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[2] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[3] = array('code'=>$langs->trans("EnterAnyCode")); @@ -493,7 +493,7 @@ $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); //$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); +$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize")); //$tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); @@ -506,7 +506,7 @@ $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc')); // List of check for fields (NOT USED YET) -$tabfieldcheck=array(); +$tabfieldcheck = array(); $tabfieldcheck[1] = array(); $tabfieldcheck[2] = array(); $tabfieldcheck[3] = array(); @@ -555,12 +555,12 @@ if (empty($sortfield)) { $tmp1 = explode(',', $tabsqlsort[$id]); $tmp2 = explode(' ', $tmp1[0]); - $sortfield=preg_replace('/^.*\./', '', $tmp2[0]); + $sortfield = preg_replace('/^.*\./', '', $tmp2[0]); } // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); -$sourceList=array(); +$sourceList = array(); if ($id == 11) { $elementList = array( @@ -585,7 +585,7 @@ if ($id == 11) 'fichinter' => $langs->trans('InterventionCard'), 'contrat' => $langs->trans('Contract'), ); - if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); complete_elementList_with_modules($elementList); @@ -602,11 +602,11 @@ if ($id == 10) { $localtax_typeList = array( "0" => $langs->trans("No"), - "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), - "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), - "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), - "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), - "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), + "1" => $langs->trans("Yes").' ('.$langs->trans("Type")." 1)", //$langs->trans("%ageOnAllWithoutVAT"), + "2" => $langs->trans("Yes").' ('.$langs->trans("Type")." 2)", //$langs->trans("%ageOnAllBeforeVAT"), + "3" => $langs->trans("Yes").' ('.$langs->trans("Type")." 3)", //$langs->trans("%ageOnProductsWithoutVAT"), + "4" => $langs->trans("Yes").' ('.$langs->trans("Type")." 4)", //$langs->trans("%ageOnProductsBeforeVAT"), + "5" => $langs->trans("Yes").' ('.$langs->trans("Type")." 5)", //$langs->trans("%ageOnServiceWithoutVAT"), "6" => $langs->trans("Yes").' ('.$langs->trans("Type")." 6)" //$langs->trans("%ageOnServiceBeforeVAT"), ); } @@ -626,37 +626,37 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', // Actions add or modify an entry into a dictionary if (GETPOST('actionadd') || GETPOST('actionmodify')) { - $listfield=explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert=explode(',', $tabfieldinsert[$id]); - $listfieldmodify=explode(',', $tabfieldinsert[$id]); - $listfieldvalue=explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); // Check that all fields are filled - $ok=1; + $ok = 1; foreach ($listfield as $f => $value) { // Discard check of mandatory fields for country for some tables - if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays','DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancysystem','DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory - if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays','DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory + if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory + if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory // Discard check of mandatory fiedls for other fields if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ($value == 'color' && empty($_POST['color'])) continue; if ($value == 'formula' && empty($_POST['formula'])) continue; - if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' - if ((! isset($_POST[$value]) || $_POST[$value]=='') - && (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy','tracking')) // Fields that are not mandatory - && (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 + if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' + if ((!isset($_POST[$value]) || $_POST[$value] == '') + && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking')) // Fields that are not mandatory + && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 ) ) { - $ok=0; - $fieldnamekey=$listfield[$f]; + $ok = 0; + $fieldnamekey = $listfield[$f]; // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; - if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays'; - if ($fieldnamekey == 'decalage') $fieldnamekey='Offset'; - if ($fieldnamekey == 'module') $fieldnamekey='Module'; + if ($fieldnamekey == 'nbjour') $fieldnamekey = 'NbOfDays'; + if ($fieldnamekey == 'decalage') $fieldnamekey = 'Offset'; + if ($fieldnamekey == 'module') $fieldnamekey = 'Module'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; if ($fieldnamekey == 'taux') $fieldnamekey = 'Rate'; @@ -673,15 +673,15 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } } // Other checks - if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system','systemauto'))) { - $ok=0; + if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system', 'systemauto'))) { + $ok = 0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } if (isset($_POST["code"])) { - if ($_POST["code"]=='0') + if ($_POST["code"] == '0') { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base @@ -690,33 +690,33 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (isset($_POST["country"]) && ($_POST["country"]=='0') && ($id != 2)) + if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2)) { - if (in_array($tablib[$id], array('DictionaryCompanyType','DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries + if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) // Field country is no mandatory for such dictionaries { - $_POST["country"]=''; + $_POST["country"] = ''; } else { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); } } - if ($id == 3 && ! is_numeric($_POST["code"])) + if ($id == 3 && !is_numeric($_POST["code"])) { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors'); } // Clean some parameters - if ((! empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 - if ((! empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 - if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null - if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null - if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null + if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) $_POST["localtax1"] = '0'; // If empty, we force to 0 + if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) $_POST["localtax2"] = '0'; // If empty, we force to 0 + if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null + if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null + if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code { - $_POST["code"]=preg_replace('/\s/', '', $_POST["code"]); + $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]); } // If check ok and action add, add the line @@ -725,13 +725,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($tabrowid[$id]) { // Get free id for insert - $newid=0; + $newid = 0; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $newid = ($obj->newid + 1); } else { dol_print_error($db); } @@ -740,16 +740,16 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) - $sql.= $tabrowid[$id].","; - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) - $sql.= $newid.","; - $i=0; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $newid.","; + $i = 0; foreach ($listfieldinsert as $f => $value) { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { @@ -758,23 +758,23 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) elseif ($value == 'entity') { $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } - if ($i) $sql.=","; + if ($i) $sql .= ","; if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql.="'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape($_POST['position'])."'"; } - elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.=",1)"; + $sql .= ",1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id'=>$id); // Clean $_POST array, we keep only } else { @@ -790,16 +790,16 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) // If verif ok and action modify, modify the line if ($ok && GETPOST('actionmodify')) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; } $i = 0; foreach ($listfieldmodify as $field) @@ -810,23 +810,23 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); } - if ($i) $sql.=","; - $sql.= $field."="; + if ($i) $sql .= ","; + $sql .= $field."="; if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position' { - $sql.="'".(int) $db->escape($_POST['position'])."'"; + $sql .= "'".(int) $db->escape($_POST['position'])."'"; } - elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; - if (in_array('entity', $listfieldmodify)) $sql.= " AND entity = '".getEntity($tabname[$id])."'"; + $sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; + if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'"; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { setEventMessages($db->error(), null, 'errors'); } @@ -841,14 +841,14 @@ if (GETPOST('actioncancel')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } - $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { @@ -864,14 +864,14 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -884,14 +884,14 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -904,14 +904,14 @@ if ($action == $acts[1]) // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -924,14 +924,14 @@ if ($action == 'activate_favorite') // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = " . (int) $entity : ''); + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : ''); } $result = $db->query($sql); @@ -947,28 +947,28 @@ if ($action == 'disable_favorite') */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); -$title=$langs->trans("DictionarySetup"); +$title = $langs->trans("DictionarySetup"); llxHeader('', $title); -$linkback=''; +$linkback = ''; if ($id) { - $title.=' - '.$langs->trans($tablib[$id]); - $linkback=''.$langs->trans("BackToDictionaryList").''; + $title .= ' - '.$langs->trans($tablib[$id]); + $linkback = ''.$langs->trans("BackToDictionaryList").''; } -$titlepicto='title_setup'; +$titlepicto = 'title_setup'; if ($id == 10 && GETPOST('from') == 'accountancy') { - $title=$langs->trans("MenuVatAccounts"); - $titlepicto='accountancy'; + $title = $langs->trans("MenuVatAccounts"); + $titlepicto = 'accountancy'; } if ($id == 7 && GETPOST('from') == 'accountancy') { - $title=$langs->trans("MenuTaxAccounts"); - $titlepicto='accountancy'; + $title = $langs->trans("MenuTaxAccounts"); + $titlepicto = 'accountancy'; } print load_fiche_titre($title, $linkback, $titlepicto); @@ -982,19 +982,19 @@ if (empty($id)) $param = '&id='.urlencode($id); -if ($search_country_id > 0) $param.= '&search_country_id='.urlencode($search_country_id); -if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); -if ($entity != '') $param.= '&entity=' . (int) $entity; +if ($search_country_id > 0) $param .= '&search_country_id='.urlencode($search_country_id); +if ($search_code != '') $param .= '&search_code='.urlencode($search_country_id); +if ($entity != '') $param .= '&entity='.(int) $entity; $paramwithsearch = $param; -if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); -if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); -if (GETPOST('from')) $paramwithsearch.= '&from='.urlencode(GETPOST('from', 'alpha')); +if ($sortorder) $paramwithsearch .= '&sortorder='.urlencode($sortorder); +if ($sortfield) $paramwithsearch .= '&sortfield='.urlencode($sortfield); +if (GETPOST('from')) $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); // Confirmation of the deletion of the line if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -1004,34 +1004,34 @@ if ($action == 'delete') if ($id) { // Complete search values request with sort criteria - $sql=$tabsql[$id]; + $sql = $tabsql[$id]; - if (! preg_match('/ WHERE /', $sql)) $sql.= " WHERE 1 = 1"; - if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id; - if ($search_code != '' && $id == 9) $sql.= natural_search("code_iso", $search_code); - elseif ($search_code != '' && $id == 28) $sql.= natural_search("h.code", $search_code); - elseif ($search_code != '' && $id == 32) $sql.= natural_search("a.code", $search_code); - elseif ($search_code != '' && $id != 9) $sql.= natural_search("code", $search_code); + if (!preg_match('/ WHERE /', $sql)) $sql .= " WHERE 1 = 1"; + if ($search_country_id > 0) $sql .= " AND c.rowid = ".$search_country_id; + if ($search_code != '' && $id == 9) $sql .= natural_search("code_iso", $search_code); + elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); + elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); + elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) { // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$db->escape($sortfield); + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= " ORDER BY ".$db->escape($sortfield); if ($sortorder) { - $sql.=" ".strtoupper($db->escape($sortorder)); + $sql .= " ".strtoupper($db->escape($sortorder)); } - $sql.=", "; + $sql .= ", "; // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]); + $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i', '', $tabsqlsort[$id]); + $tabsqlsort[$id] = preg_replace('/([a-z]+\.)?'.$sortfield.',/i', '', $tabsqlsort[$id]); } else { - $sql.=" ORDER BY "; + $sql .= " ORDER BY "; } - $sql.=$tabsqlsort[$id]; - $sql.=$db->plimit($listlimit+1, $offset); + $sql .= $tabsqlsort[$id]; + $sql .= $db->plimit($listlimit + 1, $offset); //print $sql; if (empty($tabfield[$id])) @@ -1039,7 +1039,7 @@ if ($id) dol_print_error($db, 'The table with id '.$id.' has no array tabfield defined'); exit; } - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); print '
'; print ''; @@ -1054,10 +1054,10 @@ if ($id) // Form to add a new line if ($tabname[$id]) { - $alabelisused=0; - $withentity=null; + $alabelisused = 0; + $withentity = null; - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); print '
'; print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).'
'; @@ -1072,101 +1072,101 @@ if ($id) } // Define field friendly name from its technical name - $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate - $class=''; + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = ''; - if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='maxwidth100'; } - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $class='center'; + if ($fieldlist[$field] == 'pos') { $valuetoshow = $langs->trans("Position"); $class = 'maxwidth100'; } + if ($fieldlist[$field] == 'source') { $valuetoshow = $langs->trans("Contact"); } + if ($fieldlist[$field] == 'price') { $valuetoshow = $langs->trans("PriceUHT"); } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate"); + else $valuetoshow = $langs->trans("Amount"); + $class = 'center'; } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $class="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $class="center"; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $class="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $class="center"; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - else $valuetoshow=$langs->trans("Type"); + if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $class = "center"; } + if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $class = "center"; } + if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); } + if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } + if ($fieldlist[$field] == 'type') { + if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + else $valuetoshow = $langs->trans("Type"); } - if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='maxwidth100'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') + if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); } - if ($fieldlist[$field]=='libelle_facture') { - $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + if ($fieldlist[$field] == 'libelle_facture') { + $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); } - if ($fieldlist[$field]=='country') { + if ($fieldlist[$field] == 'country') { if (in_array('region_id', $fieldlist)) { print ''; continue; } // For region page, we do not show the country input - $valuetoshow=$langs->trans("Country"); + $valuetoshow = $langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $class="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $class="center"; } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; } - if ($fieldlist[$field]=='accountancy_code') { $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell') { $valuetoshow=$langs->trans("AccountancyCodeSell"); } - if ($fieldlist[$field]=='accountancy_code_buy') { $valuetoshow=$langs->trans("AccountancyCodeBuy"); } - if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } - if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } - if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); } - if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); } - if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); } - if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); } - if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); } - if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); } - if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); } - if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } - if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } - if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } - if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("WithCounter"); } - if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } - if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); } - if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); } - if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } - if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } - if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } - if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); } + if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $class = "center"; } + if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); } + if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; } + if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); } + if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); } + if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); } + if ($fieldlist[$field] == 'unit' || $fieldlist[$field] == 'metric') { $valuetoshow = $langs->trans("MeasuringUnit"); } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $valuetoshow = ''; } + if ($fieldlist[$field] == 'accountancy_code') { $valuetoshow = $langs->trans("AccountancyCode"); } + if ($fieldlist[$field] == 'accountancy_code_sell') { $valuetoshow = $langs->trans("AccountancyCodeSell"); } + if ($fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = $langs->trans("AccountancyCodeBuy"); } + if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); } + if ($fieldlist[$field] == 'account_parent') { $valuetoshow = $langs->trans("Accountparent"); } + if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); } + if ($fieldlist[$field] == 'pcg_subtype') { $valuetoshow = $langs->trans("Pcg_subtype"); } + if ($fieldlist[$field] == 'sortorder') { $valuetoshow = $langs->trans("SortOrder"); } + if ($fieldlist[$field] == 'short_label') { $valuetoshow = $langs->trans("ShortLabel"); } + if ($fieldlist[$field] == 'range_account') { $valuetoshow = $langs->trans("Range"); } + if ($fieldlist[$field] == 'sens') { $valuetoshow = $langs->trans("Sens"); } + if ($fieldlist[$field] == 'category_type') { $valuetoshow = $langs->trans("Calculated"); } + if ($fieldlist[$field] == 'formula') { $valuetoshow = $langs->trans("Formula"); } + if ($fieldlist[$field] == 'paper_size') { $valuetoshow = $langs->trans("PaperSize"); } + if ($fieldlist[$field] == 'orientation') { $valuetoshow = $langs->trans("Orientation"); } + if ($fieldlist[$field] == 'leftmargin') { $valuetoshow = $langs->trans("LeftMargin"); } + if ($fieldlist[$field] == 'topmargin') { $valuetoshow = $langs->trans("TopMargin"); } + if ($fieldlist[$field] == 'spacex') { $valuetoshow = $langs->trans("SpaceX"); } + if ($fieldlist[$field] == 'spacey') { $valuetoshow = $langs->trans("SpaceY"); } + if ($fieldlist[$field] == 'font_size') { $valuetoshow = $langs->trans("FontSize"); } + if ($fieldlist[$field] == 'custom_x') { $valuetoshow = $langs->trans("CustomX"); } + if ($fieldlist[$field] == 'custom_y') { $valuetoshow = $langs->trans("CustomY"); } + if ($fieldlist[$field] == 'percent') { $valuetoshow = $langs->trans("Percentage"); } + if ($fieldlist[$field] == 'affect') { $valuetoshow = $langs->trans("WithCounter"); } + if ($fieldlist[$field] == 'delay') { $valuetoshow = $langs->trans("NoticePeriod"); } + if ($fieldlist[$field] == 'newbymonth') { $valuetoshow = $langs->trans("NewByMonth"); } + if ($fieldlist[$field] == 'fk_tva') { $valuetoshow = $langs->trans("VAT"); } + if ($fieldlist[$field] == 'range_ik') { $valuetoshow = $langs->trans("RangeIk"); } + if ($fieldlist[$field] == 'fk_c_exp_tax_cat') { $valuetoshow = $langs->trans("CarCategory"); } + if ($fieldlist[$field] == 'revenuestamp_type') { $valuetoshow = $langs->trans('TypeOfRevenueStamp'); } + if ($fieldlist[$field] == 'use_default') { $valuetoshow = $langs->trans('Default'); } if ($id == 2) // Special cas for state page { - if ($fieldlist[$field]=='region_id') { $valuetoshow=' '; $showfield=1; } - if ($fieldlist[$field]=='region') { $valuetoshow=$langs->trans("Country").'/'.$langs->trans("Region"); $showfield=1; } + if ($fieldlist[$field] == 'region_id') { $valuetoshow = ' '; $showfield = 1; } + if ($fieldlist[$field] == 'region') { $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; } } if ($valuetoshow != '') { - print ''; - if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + print ''; + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $valuetoshow; print ''; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; } if ($id == 4) print ''; print ''; print ''; @@ -1184,14 +1184,14 @@ if ($id) foreach ($fieldlist as $key=>$val) { if (GETPOST($val) != '') - $obj->$val=GETPOST($val); + $obj->$val = GETPOST($val); } } $tmpaction = 'create'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; if ($id == 3) unset($fieldlist[2]); // Remove field ??? if dictionary Regions @@ -1209,7 +1209,7 @@ if ($id) print ''; print ""; - $colspan=count($fieldlist)+3; + $colspan = count($fieldlist) + 3; if ($id == 4) $colspan++; print '
 '; print ''; - if (! is_null($withentity)) + if (!is_null($withentity)) print ''; print '
'; @@ -1228,7 +1228,7 @@ if ($id) // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1237,7 +1237,7 @@ if ($id) // There is several pages if ($num > $listlimit || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); print '
'; } @@ -1246,14 +1246,14 @@ if ($id) // Title line with search input fields print '
'; if ($filterfound) { - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; } print '
'; - print '
'; + print '
'; print ''; print ''; - if (! is_null($withentity)) + if (!is_null($withentity)) print ''; print ''; print ''; @@ -1412,21 +1412,21 @@ if ($id) else { $tmpaction = 'view'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { - $withentity=null; + $withentity = null; foreach ($fieldlist as $field => $value) { //var_dump($fieldlist); - $showfield=1; - $align="left"; - $valuetoshow=$obj->{$fieldlist[$field]}; + $showfield = 1; + $align = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; if ($fieldlist[$field] == 'entity') { $withentity = $valuetoshow; @@ -1435,111 +1435,111 @@ if ($id) if ($value == 'element') { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } elseif ($value == 'source') { - $valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow; + $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; } - elseif ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); + elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); } - elseif ($fieldlist[$field]=='country') { + elseif ($fieldlist[$field] == 'country') { if (empty($obj->country_code)) { - $valuetoshow='-'; + $valuetoshow = '-'; } else { - $key=$langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } } - elseif ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { - $valuetoshow=yn($valuetoshow); - $align="center"; + elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { + $valuetoshow = yn($valuetoshow); + $align = "center"; } - elseif ($fieldlist[$field]=='type_cdr') { - if(empty($valuetoshow)) $valuetoshow = $langs->trans('None'); - elseif($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth'); - elseif($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext'); - $align="center"; - } elseif ($fieldlist[$field]=='price' || preg_match('/^amount/i', $fieldlist[$field])) { - $valuetoshow=price($valuetoshow); + elseif ($fieldlist[$field] == 'type_cdr') { + if (empty($valuetoshow)) $valuetoshow = $langs->trans('None'); + elseif ($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth'); + elseif ($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext'); + $align = "center"; + } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { + $valuetoshow = price($valuetoshow); } if ($value == 'private') { $valuetoshow = yn($elementList[$valuetoshow]); } - elseif ($fieldlist[$field]=='libelle_facture') { + elseif ($fieldlist[$field] == 'libelle_facture') { $langs->load("bills"); - $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); - $valuetoshow=nl2br($valuetoshow); + $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + $valuetoshow = nl2br($valuetoshow); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { - $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + $key = $langs->trans("Country".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); - $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { - $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + $key = $langs->trans("Action".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { - $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]}); + elseif (!empty($obj->code_iso) && $fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_currencies') { + $key = $langs->trans("Currency".strtoupper($obj->code_iso)); + $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_typent') { + $key = $langs->trans(strtoupper($obj->code)); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_prospectlevel') { + $key = $langs->trans(strtoupper($obj->code)); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { - $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_civility') { + $key = $langs->trans("Civility".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_contact') { $langs->load('agenda'); - $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); - $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("PaymentType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='type' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { + elseif ($fieldlist[$field] == 'type' && $tabname[$id] == MAIN_DB_PREFIX.'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { - $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_reason') { + $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); - $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; + $key = $langs->trans($obj->code); + $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$fieldlist[$field]}; } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); - $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("SendingMethod".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); @@ -1550,17 +1550,17 @@ if ($id) $key = $langs->trans(strtoupper($obj->code)); $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; + elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; } - elseif ($fieldlist[$field]=='unicode') { + elseif ($fieldlist[$field] == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); } - elseif ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { + elseif ($fieldlist[$field] == 'label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { + elseif ($fieldlist[$field] == 'short_label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } @@ -1569,30 +1569,30 @@ if ($id) $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='localtax1' || $fieldlist[$field]=='localtax2') { - $class="center"; + elseif ($fieldlist[$field] == 'localtax1' || $fieldlist[$field] == 'localtax2') { + $class = "center"; } - elseif ($fieldlist[$field]=='localtax1_type') { + elseif ($fieldlist[$field] == 'localtax1_type') { if ($obj->localtax1 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; + $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='localtax2_type') { + elseif ($fieldlist[$field] == 'localtax2_type') { if ($obj->localtax2 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; + $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='taux') { + elseif ($fieldlist[$field] == 'taux') { $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="center"; + $align = "center"; } elseif (in_array($fieldlist[$field], array('recuperableonly'))) { - $align="center"; + $align = "center"; } - elseif ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') { + elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = length_accountg($valuetoshow); } elseif ($fieldlist[$field] == 'fk_tva') @@ -1622,12 +1622,12 @@ if ($id) $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); } - $class='tddict'; - if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; - if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; - if ($fieldlist[$field] == 'position') $class.=' right'; - if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; - if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; + $class = 'tddict'; + if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200'; + if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; + if ($fieldlist[$field] == 'position') $class .= ' right'; + if ($fieldlist[$field] == 'localtax1_type') $class .= ' nowrap'; + if ($fieldlist[$field] == 'localtax2_type') $class .= ' nowrap'; // Show value for field if ($showfield) print '
'.$valuetoshow.'
'; @@ -1730,7 +1730,7 @@ else print ''; print ''; - $showemptyline=''; + $showemptyline = ''; foreach ($taborder as $i) { if (isset($tabname[$i]) && empty($tabcond[$i])) continue; @@ -1740,13 +1740,13 @@ else if ($showemptyline) { print ''; - $showemptyline=0; + $showemptyline = 0; } - $value=$tabname[$i]; + $value = $tabname[$i]; print ''; print ''; - $lastlineisempty=false; + $lastlineisempty = false; } else { - if (! $lastlineisempty) + if (!$lastlineisempty) { - $showemptyline=1; - $lastlineisempty=true; + $showemptyline = 1; + $lastlineisempty = true; } } } @@ -1795,16 +1795,16 @@ $db->close(); */ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf,$langs,$db,$mysoc; + global $conf, $langs, $db, $mysoc; global $form; global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $elementList, $sourceList, $localtax_typeList; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $formaccounting = new FormAccounting($db); - $withentity=''; + $withentity = ''; foreach ($fieldlist as $field => $value) { @@ -1813,9 +1813,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') continue; } - if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system','systemauto'))) + if (in_array($fieldlist[$field], array('code', 'libelle', 'type')) && $tabname == MAIN_DB_PREFIX."c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) { - $hidden = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''); + $hidden = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''); print ''; } elseif ($fieldlist[$field] == 'country_id') { - if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) + if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); + $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print ''; @@ -1852,7 +1852,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0); + $region_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:0); print ''; @@ -1867,25 +1867,25 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') elseif ($fieldlist[$field] == 'element') { print ''; } // The source of the element (for contact types) elseif ($fieldlist[$field] == 'source') { print ''; } elseif ($fieldlist[$field] == 'private') { print ''; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") { - $type = (! empty($obj->type)?$obj->type:'user'); // Check if type is different of 'user' (external module) + $type = (!empty($obj->type) ? $obj->type : 'user'); // Check if type is different of 'user' (external module) print ''; @@ -1894,57 +1894,57 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { print ''; } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { if ($fieldlist[$field] == 'type_cdr') print ''; } - elseif (in_array($fieldlist[$field], array('nbjour','decalage','taux','localtax1','localtax2'))) { - $align="left"; - if (in_array($fieldlist[$field], array('taux','localtax1','localtax2'))) $align="center"; // Fields aligned on right + elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) { + $align = "left"; + if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $align = "center"; // Fields aligned on right print ''; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { - print ''; + print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } - elseif ($fieldlist[$field]=='unit') { + elseif ($fieldlist[$field] == 'unit') { print ''; } // Le type de taxe locale elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') { print ''; } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { print ''; } @@ -1998,41 +1998,41 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } else { - $fieldValue = isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''; + $fieldValue = isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''; - if ($fieldlist[$field]=='sortorder') + if ($fieldlist[$field] == 'sortorder') { - $fieldlist[$field]='position'; + $fieldlist[$field] = 'position'; } - $classtd=''; $class=''; - if ($fieldlist[$field]=='code') $class='maxwidth100'; - if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50'; - if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent'; + $classtd = ''; $class = ''; + if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; + if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class = 'maxwidth50'; + if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class = 'quatrevingtpercent'; print ''; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index dc3f8638e10..284427e4536 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","errors")); +$langs->loadLangs(array("admin", "errors")); if (!$user->admin) accessforbidden(); @@ -48,25 +48,25 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; //if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -85,14 +85,14 @@ if ($action == 'setvalue' && $user->admin) */ llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -107,7 +107,7 @@ print '
'; print ''; print ''; -$form=new Form($db); +$form = new Form($db); print '
'.$langs->trans("Table").'
   
'; - if (! empty($tabcond[$i])) + if (!empty($tabcond[$i])) { print ''.$langs->trans($tablib[$i]).''; } @@ -1762,14 +1762,14 @@ else }*/ print ''.$tabname[$i].'
'; print ''; print $langs->trans($hidden); @@ -1830,15 +1830,15 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') continue; } // For state page, we do not show the country input (we link to region, not country) print ''; - $fieldname='country'; - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); + $fieldname = 'country'; + print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); print ''; print ''; print ''; print ''; print ''; - print $form->selectarray('element', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('element', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectarray('source', $sourceList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('source', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - print $form->selectyesno("private", (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectyesno("private", (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; print $type.''; print ''; $select_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); - print $form->selectarray($fieldlist[$field], $select_list, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'2')); + print $form->selectarray($fieldlist[$field], $select_list, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'2')); print ''; else print ''; if ($fieldlist[$field] == 'type_cdr') { - print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); } else { - print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); + print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); } print ''; print ''; print ''; - $transfound=0; - $transkey=''; + $transfound = 0; + $transkey = ''; // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $transkey="PaymentCondition".strtoupper($obj->code); + $transkey = "PaymentCondition".strtoupper($obj->code); if ($langs->trans($transkey) != $transkey) { - $transfound=1; + $transfound = 1; print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); } } - if (! $transfound) + if (!$transfound) { - print ''; + print ''; } - else{ + else { print ''; } print ''; $units = array( 'mm' => $langs->trans('SizeUnitmm'), @@ -1952,29 +1952,29 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch') ); - print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); + print $form->selectarray('unit', $units, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 0, 0, 0); print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray($fieldlist[$field], $localtax_typeList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $fieldname = $fieldlist[$field]; - $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); + $accountancy_account = (!empty($obj->$fieldname) ? $obj->$fieldname : 0); print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { $fieldname = $fieldlist[$field]; - print ''; + print ''; } print ''; - $transfound=0; - $transkey=''; - if (in_array($fieldlist[$field], array('label','libelle'))) // For label + $transfound = 0; + $transkey = ''; + if (in_array($fieldlist[$field], array('label', 'libelle'))) // For label { // Special case for labels if ($tabname == MAIN_DB_PREFIX.'c_civility') { - $transkey="Civility".strtoupper($obj->code); + $transkey = "Civility".strtoupper($obj->code); } if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); - $transkey="PaymentConditionShort".strtoupper($obj->code); + $transkey = "PaymentConditionShort".strtoupper($obj->code); } if ($transkey && $langs->trans($transkey) != $transkey) { - $transfound=1; + $transfound = 1; print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); } } - if (! $transfound) + if (!$transfound) { - print ''; + print ''; } - else{ + else { print ''; } print '
'; @@ -145,7 +145,7 @@ print "\n"; print ''; -print '"; +print '"; print ''; // Name @@ -161,14 +161,14 @@ print ''; print ''; -print '"; +print '"; print ''; // User group print ''; -print '"; +print '"; print ''; // Group id @@ -194,11 +194,11 @@ print ''; */ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { - $butlabel=$langs->trans("LDAPTestSynchroGroup"); - $testlabel='testgroup'; - $key=$conf->global->LDAP_KEY_GROUPS; - $dn=$conf->global->LDAP_GROUP_DN; - $objectclass=$conf->global->LDAP_GROUP_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroGroup"); + $testlabel = 'testgroup'; + $key = $conf->global->LDAP_KEY_GROUPS; + $dn = $conf->global->LDAP_GROUP_DN; + $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -208,26 +208,26 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'testgroup') { // Creation objet - $object=new UserGroup($db); + $object = new UserGroup($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); // Get a gid number for objectclass PosixGroup if (in_array('posixGroup', $info['objectclass'])) { $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS'); } - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 2a2aff88507..adc60f8969c 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -48,23 +48,23 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey=''; - $key=GETPOST("key"); - if ($key) $valkey=$conf->global->$key; - if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -83,14 +83,14 @@ if ($action == 'setvalue' && $user->admin) */ llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (! function_exists("ldap_connect")) +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -105,7 +105,7 @@ print '
'; print ''; print ''; -$form=new Form($db); +$form = new Form($db); print '
'.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_FULLNAME)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_FULLNAME) ? ' checked' : '').">
'.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_DESCRIPTION)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_DESCRIPTION) ? ' checked' : '').">
'.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'').">global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS) ? ' checked' : '').">
'; @@ -143,21 +143,21 @@ print "\n"; print ''; -print '"; +print '"; print ''; // Description print ''; -print '"; +print '"; print ''; // User group print ''; -print '"; +print '"; print ''; print '
'.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME) ? ' checked' : '').">
'.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION) ? ' checked' : '').">
'.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)?' checked':'').">global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS) ? ' checked' : '').">
'; @@ -176,11 +176,11 @@ print ''; */ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { - $butlabel=$langs->trans("LDAPTestSynchroMemberType"); - $testlabel='testmembertype'; - $key=$conf->global->LDAP_KEY_MEMBERS_TYPES; - $dn=$conf->global->LDAP_MEMBER_TYPE_DN; - $objectclass=$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS; + $butlabel = $langs->trans("LDAPTestSynchroMemberType"); + $testlabel = 'testmembertype'; + $key = $conf->global->LDAP_KEY_MEMBERS_TYPES; + $dn = $conf->global->LDAP_MEMBER_TYPE_DN; + $objectclass = $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } @@ -190,26 +190,26 @@ if (function_exists("ldap_connect")) if ($_GET["action"] == 'testmembertype') { // Creation objet - $object=new AdherentType($db); + $object = new AdherentType($db); $object->initAsSpecimen(); // Test synchro - $ldap=new Ldap(); - $result=$ldap->connect_bind(); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info); // Get a gid number for objectclass PosixGroup if (in_array('posixGroup', $info['objectclass'])) { $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPES'); } - $result1=$ldap->delete($dn); // To be sure to delete existing records - $result2=$ldap->add($dn, $info, $user); // Now the test - $result3=$ldap->delete($dn); // Clean what we did + $result1 = $ldap->delete($dn); // To be sure to delete existing records + $result2 = $ldap->add($dn, $info, $user); // Now the test + $result3 = $ldap->delete($dn); // Clean what we did if ($result2 > 0) { diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index ccc33ab3cee..a97952cb2df 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -26,7 +26,7 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'loan')); @@ -38,7 +38,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); // Other parameters LOAN_* -$list = array ( +$list = array( 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' @@ -60,7 +60,7 @@ if ($action == 'update') } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -77,9 +77,9 @@ if ($action == 'update') llxHeader(); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup'); print '
'; @@ -91,7 +91,7 @@ print ''; */ print ''; print ''; -print ''; +print ''; print "\n"; foreach ($list as $key) @@ -104,7 +104,7 @@ foreach ($list as $key) // Value print ''; print ''; print ''; @@ -361,15 +361,15 @@ if ($action == 'create') { print ''; } print ''; // Mainmenu code print ''; - print ''; + print ''; print ''; @@ -382,7 +382,7 @@ if ($action == 'create') } else { - print ''; + print ''; } print ''; // Position - print ''; + print ''; // Target print ''; // Enabled - print ''; + print ''; // Perms - print ''; + print ''; print '
' . $langs->trans('Options') . ''.$langs->trans('Options').'
'; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index f0ebb0f7794..b55edaa4ba7 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -29,32 +29,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; // Load translation files required by the page -$langs->loadLangs(array("other","admin")); +$langs->loadLangs(array("other", "admin")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $dirstandard = array(); $dirsmartphone = array(); -$dirmenus=array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); -foreach($dirmenus as $dirmenu) +$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); +foreach ($dirmenus as $dirmenu) { - $dirstandard[]=$dirmenu.'standard'; - $dirsmartphone[]=$dirmenu.'smartphone'; + $dirstandard[] = $dirmenu.'standard'; + $dirsmartphone[] = $dirmenu.'smartphone'; } -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); -$menu_handler_top=$conf->global->MAIN_MENU_STANDARD; -$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE; -$menu_handler_top=preg_replace('/_backoffice.php/i', '', $menu_handler_top); -$menu_handler_top=preg_replace('/_frontoffice.php/i', '', $menu_handler_top); -$menu_handler_smartphone=preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone); -$menu_handler_smartphone=preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone); +$menu_handler_top = $conf->global->MAIN_MENU_STANDARD; +$menu_handler_smartphone = $conf->global->MAIN_MENU_SMARTPHONE; +$menu_handler_top = preg_replace('/_backoffice.php/i', '', $menu_handler_top); +$menu_handler_top = preg_replace('/_frontoffice.php/i', '', $menu_handler_top); +$menu_handler_smartphone = preg_replace('/_backoffice.php/i', '', $menu_handler_smartphone); +$menu_handler_smartphone = preg_replace('/_frontoffice.php/i', '', $menu_handler_smartphone); -$menu_handler=$menu_handler_top; +$menu_handler = $menu_handler_top; -if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine"); -if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler"); +if (GETPOST("handler_origine")) $menu_handler = GETPOST("handler_origine"); +if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); @@ -64,53 +64,53 @@ if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler"); if ($action == 'update') { - if (! $_POST['cancel']) + if (!$_POST['cancel']) { - $leftmenu=''; $mainmenu=''; - if (! empty($_POST['menuIdParent']) && ! is_numeric($_POST['menuIdParent'])) + $leftmenu = ''; $mainmenu = ''; + if (!empty($_POST['menuIdParent']) && !is_numeric($_POST['menuIdParent'])) { - $tmp=explode('&', $_POST['menuIdParent']); - foreach($tmp as $s) + $tmp = explode('&', $_POST['menuIdParent']); + foreach ($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) { - $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } if (preg_match('/fk_leftmenu=/', $s)) { - $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } } $menu = new Menubase($db); - $result=$menu->fetch(GETPOST('menuId', 'int')); + $result = $menu->fetch(GETPOST('menuId', 'int')); if ($result > 0) { - $menu->titre=GETPOST('titre', 'alpha'); // deprecated - $menu->title=GETPOST('titre', 'alpha'); - $menu->leftmenu=GETPOST('leftmenu', 'aZ09'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); - $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); + $menu->titre = GETPOST('titre', 'alpha'); // deprecated + $menu->title = GETPOST('titre', 'alpha'); + $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); if (is_numeric(GETPOST('menuIdParent', 'alpha'))) { - $menu->fk_menu=GETPOST('menuIdParent', 'alpha'); + $menu->fk_menu = GETPOST('menuIdParent', 'alpha'); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; - else $menu->fk_menu=-1; - $menu->fk_mainmenu=$mainmenu; - $menu->fk_leftmenu=$leftmenu; + if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; + else $menu->fk_menu = -1; + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; } - $result=$menu->update($user); + $result = $menu->update($user); if ($result > 0) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); @@ -144,91 +144,91 @@ if ($action == 'add') exit; } - $leftmenu=''; $mainmenu=''; - if (GETPOST('menuId', 'alpha', 3) && ! is_numeric(GETPOST('menuId', 'alpha', 3))) + $leftmenu = ''; $mainmenu = ''; + if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3))) { - $tmp=explode('&', GETPOST('menuId', 'alpha', 3)); - foreach($tmp as $s) + $tmp = explode('&', GETPOST('menuId', 'alpha', 3)); + foreach ($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) { - $mainmenu=preg_replace('/fk_mainmenu=/', '', $s); + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); } if (preg_match('/fk_leftmenu=/', $s)) { - $leftmenu=preg_replace('/fk_leftmenu=/', '', $s); + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); } } } $langs->load("errors"); - $error=0; - if (! $error && ! $_POST['menu_handler']) + $error = 0; + if (!$error && !$_POST['menu_handler']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['type']) + if (!$error && !$_POST['type']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['url']) + if (!$error && !$_POST['url']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['titre']) + if (!$error && !$_POST['titre']) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $action = 'create'; $error++; } - if (! $error && $_POST['menuId'] && $_POST['type'] == 'top') + if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') { setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); $action = 'create'; $error++; } - if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left') + if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') { setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); $action = 'create'; $error++; } - if (! $error) + if (!$error) { $menu = new Menubase($db); - $menu->menu_handler=preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); - $menu->type=GETPOST('type', 'alpha'); - $menu->titre=GETPOST('titre', 'alpha'); // deprecated - $menu->title=GETPOST('titre', 'alpha'); - $menu->url=GETPOST('url', 'alpha'); - $menu->langs=GETPOST('langs', 'alpha'); - $menu->position=GETPOST('position', 'int'); - $menu->enabled=GETPOST('enabled', 'alpha'); - $menu->perms=GETPOST('perms', 'alpha'); - $menu->target=GETPOST('target', 'alpha'); - $menu->user=GETPOST('user', 'alpha'); - $menu->mainmenu=GETPOST('propertymainmenu', 'alpha'); + $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); + $menu->type = GETPOST('type', 'alpha'); + $menu->titre = GETPOST('titre', 'alpha'); // deprecated + $menu->title = GETPOST('titre', 'alpha'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); if (is_numeric(GETPOST('menuId', 'alpha', 3))) { - $menu->fk_menu=GETPOST('menuId', 'alpha', 3); + $menu->fk_menu = GETPOST('menuId', 'alpha', 3); } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu=0; - else $menu->fk_menu=-1; - $menu->fk_mainmenu=$mainmenu; - $menu->fk_leftmenu=$leftmenu; + if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; + else $menu->fk_menu = -1; + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; } - $result=$menu->create($user); + $result = $menu->create($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09')); @@ -248,7 +248,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); - $result=$db->query($sql); + $result = $db->query($sql); if ($result == 0) { @@ -257,14 +257,14 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') llxHeader(); setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); llxFooter(); - exit ; + exit; } else { $this->db->rollback(); $reload = 0; - $_GET["action"]=''; + $_GET["action"] = ''; } } @@ -274,8 +274,8 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); llxHeader('', $langs->trans("Menu")); @@ -320,7 +320,7 @@ if ($action == 'create') if (GETPOST('menuId', 'int')) { $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); - $res = $db->query($sql); + $res = $db->query($sql); if ($res) { while ($menu = $db->fetch_array($res)) @@ -337,7 +337,7 @@ if ($action == 'create') // Handler print '
'.$langs->trans('MenuHandler').''; - $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler)?'':'_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); + $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); print ''.$langs->trans('DetailMenuHandler').'
'.$langs->trans('DetailType').'
'.$langs->trans('MainMenuCode').''; print $langs->trans("Example").': mytopmenukey'; print '
'.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; @@ -398,19 +398,19 @@ if ($action == 'create') print '
'.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
'.$langs->trans('Rights').''.$langs->trans('DetailRight').'
'.$langs->trans('Rights').''.$langs->trans('DetailRight').'
'; @@ -439,7 +439,7 @@ elseif ($action == 'edit') print ''; $menu = new Menubase($db); - $result=$menu->fetch(GETPOST('menuId', 'int')); + $result = $menu->fetch(GETPOST('menuId', 'int')); //var_dump($menu); // Id @@ -455,9 +455,9 @@ elseif ($action == 'edit') // User print ''; // Type @@ -473,7 +473,7 @@ elseif ($action == 'edit') } else {*/ - print ''; + print ''; //} print ''; - $valtouse=$menu->fk_menu; - if ($menu->fk_mainmenu) $valtouse='fk_mainmenu='.$menu->fk_mainmenu; - if ($menu->fk_leftmenu) $valtouse.='&fk_leftmenu='.$menu->fk_leftmenu; + $valtouse = $menu->fk_menu; + if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu; + if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; print ''; print ''; // Enabled print ''; // Perms print ''; print '
'.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
mainmenu).'">mainmenu).'">'; print $langs->trans("Example").': mytopmenukey'; @@ -483,9 +483,9 @@ elseif ($action == 'edit') // MenuId Parent print '
'.$langs->trans('MenuIdParent'); print ''.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; @@ -508,18 +508,18 @@ elseif ($action == 'edit') // Target print '
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled'); - if (! empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; + if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; print '
'.$langs->trans('Rights').''.$langs->trans('DetailRight'); - if (! empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; + if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; print '
'; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 515340efe89..d6a7fb26a98 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; $langs->loadLangs(array('admin', 'multicurrency')); // Access control -if (! $user->admin) { +if (!$user->admin) { accessforbidden(); } @@ -48,8 +48,8 @@ $action = GETPOST('action', 'alpha'); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; - $value=GETPOST($code, 'alpha'); + $code = $reg[1]; + $value = GETPOST($code, 'alpha'); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -62,7 +62,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -75,7 +75,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if ($action == 'add_currency') { - $error=0; + $error = 0; $langs->loadCacheCurrencies(''); @@ -90,7 +90,7 @@ if ($action == 'add_currency') setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { if ($currency->create($user) > 0) { @@ -115,12 +115,12 @@ elseif ($action == 'update_currency') setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { if ($currency->fetch($fk_multicurrency) > 0) { - $result=$currency->updateRate($rate); - if ($result<0) { + $result = $currency->updateRate($rate); + if ($result < 0) { setEventMessages(null, $currency->errors, 'errors'); } } @@ -171,14 +171,14 @@ if ($resql) * View */ -$form=new Form($db); +$form = new Form($db); $page_name = "MultiCurrencySetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback); // Configuration header @@ -272,7 +272,7 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) print '
'; print ''; - $urlforapilayer='https://currencylayer.com'; //https://apilayer.net + $urlforapilayer = 'https://currencylayer.com'; //https://apilayer.net print ''; print ''."\n"; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index fb2be946169..eb6f8d18fe4 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -47,45 +47,45 @@ if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); if ($result < 0) $error++; - if (! $error && is_array($_POST)) + if (!$error && is_array($_POST)) { //var_dump($_POST); - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if (! preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; + if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; - $newval=''; - $newkey=''; + $newval = ''; + $newkey = ''; - $shortkey=preg_replace('/_key$/', '', $key); + $shortkey = preg_replace('/_key$/', '', $key); //print $shortkey.'
'; if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) { dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity); - $newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval=GETPOST($shortkey.'_key'); + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); //print $newkey.' - '.$newval.'
'; } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) { // Add a new entry - $newkey='NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval=GETPOST($shortkey.'_key'); + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); } if ($newkey && $newval) { - $result=dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); } } } - if (! $error) + if (!$error) { $db->commit(); @@ -105,17 +105,17 @@ if ($action == 'setvalue' && $user->admin) * View */ -$form=new Form($db); +$form = new Form($db); $notify = new Notify($db); llxHeader('', $langs->trans("NotificationSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_setup'); print $langs->trans("NotificationsDesc").'
'; print $langs->trans("NotificationsDescUser").'
'; -if (! empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'
'; +if (!empty($conf->societe->enabled)) print $langs->trans("NotificationsDescContact").'
'; print $langs->trans("NotificationsDescGlobal").'
'; print '
'; @@ -133,7 +133,7 @@ print ''; print ''; print ''; print '
'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'
'; print $langs->trans("NotificationEMailFrom").''; print ''; -if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); +if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("ErrorBadEMail")); print '
'; @@ -142,8 +142,8 @@ print '

'; // Notification per contacts -$title=$langs->trans("ListOfNotificationsPerUser"); -if (! empty($conf->societe->enabled)) $title=$langs->trans("ListOfNotificationsPerUserOrContact"); +$title = $langs->trans("ListOfNotificationsPerUser"); +if (!empty($conf->societe->enabled)) $title = $langs->trans("ListOfNotificationsPerUserOrContact"); print load_fiche_titre($title, '', ''); print ''; @@ -155,16 +155,16 @@ print ''; print "\n"; // Load array of available notifications -$notificationtrigger=new InterfaceNotification($db); -$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); +$notificationtrigger = new InterfaceNotification($db); +$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); print ''; print ''; print '
'.$langs->trans("Label").'
'; -$i=0; -foreach($listofnotifiedevents as $notifiedevent) +$i = 0; +foreach ($listofnotifiedevents as $notifiedevent) { - $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); @@ -185,7 +185,7 @@ print '
'; print '
'; print '* '.$langs->trans("GoOntoUserCardToAddMore").'
'; -if (! empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'
'; +if (!empty($conf->societe->enabled)) print '** '.$langs->trans("GoOntoContactCardToAddMore").'
'; print '
'; print '

'; @@ -203,12 +203,12 @@ print '
'.'
'.$label.''; // Notification with threshold - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - $param='NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; - $value=GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key')?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha'):$conf->global->$param; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; + $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; - $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - $arrayemail=explode(',', $value); - $showwarning=0; - foreach($arrayemail as $keydet => $valuedet) + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $arrayemail = explode(',', $value); + $showwarning = 0; + foreach ($arrayemail as $keydet => $valuedet) { - $valuedet=trim($valuedet); - if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++; + $valuedet = trim($valuedet); + if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++; } - if ((! empty($conf->global->$param)) && $showwarning) $s.=' '.img_warning($langs->trans("ErrorBadEMail")); + if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
'; } // New entry input fields - $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
'; // Notification with threshold - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; print $langs->trans("AmountHT").' >= '; print '
'; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 780f22894e9..25afbaad943 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // 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 // Load translation files required by the page @@ -60,7 +60,7 @@ if ($action == 'update') $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null); } else { @@ -76,7 +76,7 @@ llxHeader(); $form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); print ''; @@ -92,29 +92,29 @@ print $langs->trans("ListOfSupportedOauthProviders").'

'; print ''; -$i=0; +$i = 0; // $list is defined into oauth.lib.php foreach ($list as $key) { - $supported=0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; - if (! $supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported $i++; - print ''; + print ''; // Api Name $label = $langs->trans($key[0]); print ''; print ''; print ''; if ($supported) { - $redirect_uri=$urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; print ''; print ''; print '\n"; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("OAuthIDSecret").''; print ''."\n"; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("IsTokenGenerated"); print ''; @@ -270,7 +270,7 @@ if ($mode == 'setup' && $user->admin) print ''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("Token").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_REFRESH").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_EXPIRED").''; print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_EXPIRE_AT").''; print '
'.$label.''; - if (! empty($key[3])) print $langs->trans($key[3]); + if (!empty($key[3])) print $langs->trans($key[3]); print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 125ef2458b7..01d36898c78 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -31,7 +31,7 @@ use OAuth\Common\Storage\DoliStorage; // Load translation files required by the page $langs->loadLangs(array('admin', 'printing', 'oauth')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -39,9 +39,9 @@ $value = GETPOST('value', 'alpha'); $varname = GETPOST('varname', 'alpha'); $driver = GETPOST('driver', 'alpha'); -if (! empty($driver)) $langs->load($driver); +if (!empty($driver)) $langs->load($driver); -if (!$mode) $mode='setup'; +if (!$mode) $mode = 'setup'; /* @@ -57,15 +57,15 @@ if (!$mode) $mode='setup'; if ($action == 'setconst' && $user->admin) { - $error=0; + $error = 0; $db->begin(); foreach ($_POST['setupdriver'] as $setupconst) { //print '
'.print_r($setupconst, true).'
'; - $result=dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); - if (! $result > 0) $error++; + $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); + if (!$result > 0) $error++; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); @@ -75,17 +75,17 @@ if ($action == 'setconst' && $user->admin) $db->rollback(); dol_print_error($db); } - $action=''; + $action = ''; } if ($action == 'setvalue' && $user->admin) { $db->begin(); - $result=dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); - if (! $result > 0) $error++; + $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); + if (!$result > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null); @@ -104,15 +104,15 @@ if ($action == 'setvalue' && $user->admin) */ // 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 $form = new Form($db); llxHeader('', $langs->trans("PrintingSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); $head = oauthadmin_prepare_head(); @@ -124,52 +124,52 @@ if ($mode == 'setup' && $user->admin) { print $langs->trans("OAuthSetupForLogin")."

\n"; - foreach($list as $key) + foreach ($list as $key) { - $supported=0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported=1; - if (! $supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported - $OAUTH_SERVICENAME='Unknown'; + $OAUTH_SERVICENAME = 'Unknown'; if ($key[0] == 'OAUTH_GITHUB_NAME') { - $OAUTH_SERVICENAME='GitHub'; - $urltorenew=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=$urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltocheckperms='https://github.com/settings/applications/'; + $OAUTH_SERVICENAME = 'GitHub'; + $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?state=user,public_repo&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms = 'https://github.com/settings/applications/'; } elseif ($key[0] == 'OAUTH_GOOGLE_NAME') { - $OAUTH_SERVICENAME='Google'; - $urltorenew=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltocheckperms='https://security.google.com/settings/security/permissions'; + $OAUTH_SERVICENAME = 'Google'; + $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltocheckperms = 'https://security.google.com/settings/security/permissions'; } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') { - $OAUTH_SERVICENAME='StripeTest'; - $urltorenew=$urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=''; - $urltocheckperms=''; + $OAUTH_SERVICENAME = 'StripeTest'; + $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = ''; + $urltocheckperms = ''; } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') { - $OAUTH_SERVICENAME='StripeLive'; - $urltorenew=$urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); - $urltodelete=''; - $urltocheckperms=''; + $OAUTH_SERVICENAME = 'StripeLive'; + $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); + $urltodelete = ''; + $urltocheckperms = ''; } else { - $urltorenew=''; - $urltodelete=''; - $urltocheckperms=''; + $urltorenew = ''; + $urltodelete = ''; + $urltocheckperms = ''; } // Show value of token - $tokenobj=null; + $tokenobj = null; // Token require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; @@ -179,14 +179,14 @@ if ($mode == 'setup' && $user->admin) { $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); } - catch(Exception $e) + catch (Exception $e) { // Return an error if token not found } // Set other properties - $refreshtoken=false; - $expiredat=''; + $refreshtoken = false; + $expiredat = ''; $expire = false; // Is token expired or will token expire in the next 30 seconds @@ -209,12 +209,12 @@ if ($mode == 'setup' && $user->admin) } else { - $expiredat=dol_print_date($endoflife, "dayhour"); + $expiredat = dol_print_date($endoflife, "dayhour"); } } } - $submit_enabled=0; + $submit_enabled = 0; print ''; print ''; @@ -230,7 +230,7 @@ if ($mode == 'setup' && $user->admin) print "
'; @@ -241,7 +241,7 @@ if ($mode == 'setup' && $user->admin) print '
'; @@ -292,7 +292,7 @@ if ($mode == 'setup' && $user->admin) { // Token refresh print '
'; @@ -302,7 +302,7 @@ if ($mode == 'setup' && $user->admin) // Token expired print '
'; @@ -312,7 +312,7 @@ if ($mode == 'setup' && $user->admin) // Token expired at print '
'; @@ -323,7 +323,7 @@ if ($mode == 'setup' && $user->admin) print '
'; - if (! empty($driver)) + if (!empty($driver)) { if ($submit_enabled) { print '
'; @@ -340,7 +340,7 @@ if ($mode == 'test' && $user->admin) print $langs->trans('PrintTestDesc'.$driver)."

\n"; print ''; - if (! empty($driver)) + if (!empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; $classname = 'printing_'.$driver; @@ -348,7 +348,7 @@ if ($mode == 'test' && $user->admin) $printer = new $classname($db); //print '
'.print_r($printer, true).'
'; if (count($printer->getlistAvailablePrinters())) { - if ($printer->listAvailablePrinters()==0) { + if ($printer->listAvailablePrinters() == 0) { print $printer->resprint; } else { setEventMessages($printer->error, $printer->errors, 'errors'); @@ -379,7 +379,7 @@ if ($mode == 'userconf' && $user->admin) print "\n"; $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $resql = $db->query($sql); - while ($row=$db->fetch_array($resql)) { + while ($row = $db->fetch_array($resql)) { print ''; print ''; print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index da04a88ac2c..144eabf9aab 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha'); */ if ($cancel) { - $action=''; + $action = ''; } if ($action == 'update') @@ -102,12 +102,12 @@ elseif ($action == 'disable_pdfsecurity') * View */ -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$form=new Form($db); -$formother=new FormOther($db); -$formadmin=new FormAdmin($db); +$form = new Form($db); +$formother = new FormOther($db); +$formadmin = new FormAdmin($db); $arraydetailsforpdffoot = array( 0 => $langs->transnoentitiesnoconv('NoDetails'), @@ -137,8 +137,8 @@ print '
'; print '
'.$row['login'].''.$row['module'].'
'; print ''; -$selected=$conf->global->MAIN_PDF_FORMAT; -if (empty($selected)) $selected=dol_getDefaultFormat(); +$selected = $conf->global->MAIN_PDF_FORMAT; +if (empty($selected)) $selected = dol_getDefaultFormat(); // Show pdf format @@ -147,16 +147,16 @@ print $formadmin->select_paper_format($selected, 'MAIN_PDF_FORMAT'); print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_TOP").''; -print ''; +print ''; print '
'.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; -print ''; +print ''; print '
'; @@ -175,16 +175,16 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("ShowVATIntaInAddress").''; -print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (! empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))?$conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS:0, 1); +print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1); print '
'.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; - print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant)?$conf->global->$keyforconstant:0, 1, $noCountryCode); + print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); print '
' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)) . ''; - $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); + $text = '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).''; + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); $text .= '
' . $langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)) . ''; - $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); - $text.= '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).''; + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); + $text .= '
'.$langs->trans("Parameter").''.$langs->trans("HideAnyVATInformationOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1); print '
'.$langs->trans("Parameter").''.$langs->trans("HideDescOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1); print '
'.$langs->trans("HideRefOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1); print '
'.$langs->trans("HideDetailsOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1); +print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); print '
'.$langs->trans("SwapSenderAndRecipientOnPDF").''; -print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))?$conf->global->MAIN_INVERT_SENDER_RECIPIENT:0, 1); +print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); print '
'.$langs->trans("PlaceCustomerAddressToIsoLocation").''; -print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (! empty($conf->global->MAIN_PDF_USE_ISO_LOCATION))?$conf->global->MAIN_PDF_USE_ISO_LOCATION:0, 1); +print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); print '
'.$langs->trans("LibraryToBuildPDF").''; -$i=0; -$pdf=pdf_getInstance('A4'); -if (class_exists('FPDF') && ! class_exists('TCPDF')) +$i = 0; +$pdf = pdf_getInstance('A4'); +if (class_exists('FPDF') && !class_exists('TCPDF')) { if ($i) print ' + '; print 'FPDF'; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9be75bf125b..1760651b693 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -27,22 +27,22 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); // Load translation files required by the page -$langs->loadLangs(array("users","admin","other")); +$langs->loadLangs(array("users", "admin", "other")); if (!$user->admin) accessforbidden(); // Allow/Disallow change to clear passwords once passwords are crypted -$allow_disable_encryption=true; +$allow_disable_encryption = true; /* * Actions */ if ($action == 'setgeneraterule') { - if (! dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) + if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) { dol_print_error($db); } @@ -55,33 +55,33 @@ if ($action == 'setgeneraterule') if ($action == 'activate_encrypt') { - $error=0; + $error = 0; $db->begin(); dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $numrows=$db->num_rows($resql); - $i=0; + $numrows = $db->num_rows($resql); + $i = 0; while ($i < $numrows) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if (dol_hash($obj->pass)) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql.= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; - $sql.= " WHERE rowid=".$obj->rowid; + $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; + $sql .= " WHERE rowid=".$obj->rowid; //print $sql; $resql2 = $db->query($sql); - if (! $resql2) + if (!$resql2) { dol_print_error($db); $error++; @@ -96,7 +96,7 @@ if ($action == 'activate_encrypt') //print $error." ".$sql; //exit; - if (! $error) + if (!$error) { $db->commit(); header("Location: security.php"); @@ -125,7 +125,7 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(1); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); @@ -142,7 +142,7 @@ elseif ($action == 'disable_encryptdbpassconf') $result = encodedecode_dbpassconf(0); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); @@ -196,7 +196,7 @@ if ($action == 'maj_pattern') */ $form = new Form($db); -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Passwords"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -205,7 +205,7 @@ print $langs->trans("GeneratedPasswordDesc")."
\n"; print "
\n"; -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1); @@ -220,11 +220,11 @@ print ''; // Charge tableau des modules generation $dir = "../core/modules/security/generate"; clearstatcache(); -$handle=opendir($dir); -$i=1; +$handle = opendir($dir); +$i = 1; if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) { @@ -233,7 +233,7 @@ if (is_resource($handle)) require_once $dir.'/'.$file; $obj = new $classname($db, $conf, $langs, $user); - $arrayhandler[$obj->id]=$obj; + $arrayhandler[$obj->id] = $obj; $i++; } } @@ -251,7 +251,7 @@ print '
'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; @@ -298,37 +298,37 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; - print '"; + print '"; print ''; print ''; print ''; - print '"; + print '"; print ''; print ''; print ''; - print '"; + print '"; print ''; print ''; print ''; - print '"; + print '"; print ''; print ''; print ''; - print '"; + print '"; print ''; print ''; print ''; - print '"; + print '"; print ''; print ''; @@ -398,7 +398,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ // Cryptage mot de passe print '
'; -print ""; +print ""; print ''; print ""; @@ -413,12 +413,12 @@ print ''; print ''; print ''; print ''; -if (! $conf->global->DATABASE_PWD_ENCRYPTED) +if (!$conf->global->DATABASE_PWD_ENCRYPTED) { print ''; print ''; print ''; print ''; print ''; print ''; print '
' . $langs->trans("MinLength")."'.$langs->trans("MinLength")."
' . $langs->trans("NbMajMin")."'.$langs->trans("NbMajMin")."
' . $langs->trans("NbNumMin")."'.$langs->trans("NbNumMin")."
' . $langs->trans("NbSpeMin")."'.$langs->trans("NbSpeMin")."
' . $langs->trans("NbIteConsecutive")."'.$langs->trans("NbIteConsecutive")."
' . $langs->trans("NoAmbiCaracAutoGeneration")."'.$langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'.$langs->trans("DoNotStoreClearPassword").''; -if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) +if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print img_picto($langs->trans("Active"), 'tick'); } print ''; print ''.$langs->trans("Activate").''; @@ -426,7 +426,7 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED) } // Database conf file encryption -if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) +if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print ''; if ($allow_disable_encryption) @@ -449,7 +449,7 @@ print '
'.$langs->trans("MainDbPasswordFileConfEncrypted").''; -if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) +if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { print img_picto($langs->trans("Active"), 'tick'); } @@ -468,7 +468,7 @@ else { print ''.$langs->trans("Activate").''; } - if (! empty($dolibarr_main_db_encrypted_pass)) + if (!empty($dolibarr_main_db_encrypted_pass)) { print ''.$langs->trans("Disable").''; } @@ -484,7 +484,7 @@ print '
'.$langs->trans("DisableForgetPasswordLinkOnLogonPage").''; -if(! empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) +if (!empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { print img_picto($langs->trans("Active"), 'tick'); } diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 181ecad5c6b..aeb2ee0fe19 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -31,19 +31,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page $langs->loadLangs(array('users', 'admin', 'other')); -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -$upload_dir=$conf->admin->dir_temp; +$upload_dir = $conf->admin->dir_temp; /* * Actions */ -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -52,15 +52,15 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'updateform') { - $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe - $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" - $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command - $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params + $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'none'); // Use GETPOST none because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe + $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'none'); // Use GETPOST none because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" + $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command + $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params - $res3=dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); - $res6=dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); if ($res3 && $res4 && $res5 && $res6) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } @@ -70,8 +70,8 @@ if ($action == 'updateform') elseif ($action == 'delete') { $langs->load("other"); - $file = $conf->admin->dir_temp . '/' . GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file); + $file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile', 'alpha')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors'); Header('Location: '.$_SERVER["PHP_SELF"]); @@ -85,7 +85,7 @@ elseif ($action == 'delete') $form = new Form($db); -$wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; +$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Files"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); @@ -98,13 +98,13 @@ print ''; print ''; print ''; -$head=security_prepare_head(); +$head = security_prepare_head(); dol_fiche_head($head, 'file', $langs->trans("Security"), -1); // Upload options -$var=false; +$var = false; print '
'; print ''; @@ -115,8 +115,8 @@ print ''; print ''; print ''; print ''; print '"; print ''; @@ -164,7 +164,7 @@ print ''; print '"; print ''; @@ -180,11 +180,11 @@ print ''; // Form to test upload print '
'; -$formfile=new FormFile($db); +$formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0); // List of document -$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); +$filearray = dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); $formfile->list_of_documents($filearray, null, 'admin_temp', ''); // End of page diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index ce4161ea147..021d6d99d4e 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -26,12 +26,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","admin","products","sms","other","errors")); +$langs->loadLangs(array("companies", "admin", "products", "sms", "other", "errors")); if (!$user->admin) accessforbidden(); -$substitutionarrayfortest=array( +$substitutionarrayfortest = array( '__ID__' => 'TESTIdRecord', '__PHONEFROM__' => 'TESTPhoneFrom', '__PHONETO__' => 'TESTPhoneTo', @@ -39,7 +39,7 @@ $substitutionarrayfortest=array( '__FIRSTNAME__' => 'TESTFirstname' ); -$action=GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); /* @@ -63,16 +63,16 @@ if ($action == 'update' && empty($_POST["cancel"])) /* * Send sms */ -if ($action == 'send' && ! $_POST['cancel']) +if ($action == 'send' && !$_POST['cancel']) { - $error=0; + $error = 0; - $smsfrom=''; - if (! empty($_POST["fromsms"])) $smsfrom=GETPOST("fromsms"); - if (empty($smsfrom)) $smsfrom=GETPOST("fromname"); + $smsfrom = ''; + if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms"); + if (empty($smsfrom)) $smsfrom = GETPOST("fromname"); $sendto = GETPOST("sendto"); $body = GETPOST('message'); - $deliveryreceipt= GETPOST("deliveryreceipt"); + $deliveryreceipt = GETPOST("deliveryreceipt"); $deferred = GETPOST('deferred'); $priority = GETPOST('priority'); $class = GETPOST('class'); @@ -82,40 +82,40 @@ if ($action == 'send' && ! $_POST['cancel']) include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - if (! empty($formsms->error)) + if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); - $action='test'; + $action = 'test'; $error++; } if (empty($body)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (empty($smsfrom) || ! str_replace('+', '', $smsfrom)) + if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (empty($sendto) || ! str_replace('+', '', $sendto)) + if (empty($sendto) || !str_replace('+', '', $sendto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); - $action='test'; + $action = 'test'; $error++; } - if (! $error) + if (!$error) { // Make substitutions into message complete_substitutions_array($substitutionarrayfortest, $langs); - $body=make_substitutions($body, $substitutionarrayfortest); + $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; - $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account - $result=$smsfile->sendfile(); // This send SMS + $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account + $result = $smsfile->sendfile(); // This send SMS if ($result) { @@ -128,7 +128,7 @@ if ($action == 'send' && ! $_POST['cancel']) setEventMessages($smsfile->error, $smsfile->errors, 'errors'); } - $action=''; + $action = ''; } } @@ -138,11 +138,11 @@ if ($action == 'send' && ! $_POST['cancel']) * View */ -$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; -$wikihelp='EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; +$wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SmsSetup"), '', 'title_setup'); @@ -151,14 +151,14 @@ print ''.$langs->trans("SmsDesc")."
\n"; print "
\n"; // List of sending methods -$listofmethods=(is_array($conf->modules_parts['sms'])?$conf->modules_parts['sms']:array()); +$listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array()); asort($listofmethods); if ($action == 'edit') { - $form=new Form($db); + $form = new Form($db); - if (! count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; + if (!count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; print ''; print ''; @@ -185,7 +185,7 @@ if ($action == 'edit') // From print ''; - print ''; // Autocopy to @@ -197,7 +197,7 @@ if ($action == 'edit') print '
'.$langs->trans("MaxSizeForUploadedFiles").'.'; -$max=@ini_get('upload_max_filesize'); -if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max*1024, $langs->trans("Kb")).'.'; +$max = @ini_get('upload_max_filesize'); +if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit", $max * 1024, $langs->trans("Kb")).'.'; else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; print ''; @@ -142,18 +142,18 @@ print $langs->trans("AntiVirusCommandExample"); // Check command in inside safe_mode print ''; -if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) +if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { $langs->load("errors"); - $basedir=preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); - $listdir=explode(';', ini_get('safe_mode_exec_dir')); - if (! in_array($basedir, $listdir)) + $basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); + $listdir = explode(';', ini_get('safe_mode_exec_dir')); + if (!in_array($basedir, $listdir)) { print img_warning($langs->trans('WarningSafeModeOnCheckExecDir')); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; print "
'.$langs->trans("AntiVirusParam").'
'; print $langs->trans("AntiVirusParamExample"); print '
'; -print ''; +print ''; print "
'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'
'; print '
'; - print ''; + print ''; print '     '; print ''; print '
'; @@ -207,7 +207,7 @@ if ($action == 'edit') } else { - if (! count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; + if (!count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; print ''; print ''; @@ -220,15 +220,15 @@ else // Method print ''; // From print ''; print ''; // Autocopy to @@ -260,7 +260,7 @@ else print ''.$langs->trans("DoTestServerAvailability").''; }*/ - if (count($listofmethods) && ! empty($conf->global->MAIN_SMS_SENDMODE)) + if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { print ''.$langs->trans("DoTestSend").''; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index e822371bc4f..695d5363f78 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -30,15 +30,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("install","other","admin")); +$langs->loadLangs(array("install", "other", "admin")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -if (! $user->admin) +if (!$user->admin) accessforbidden(); $sfurl = ''; -$version='0.0'; +$version = '0.0'; @@ -58,9 +58,9 @@ if ($action == 'getlastversion') * View */ -$form=new Form($db); +$form = new Form($db); -$title=$langs->trans("InfoDolibarr"); +$title = $langs->trans("InfoDolibarr"); llxHeader('', $title); @@ -91,39 +91,39 @@ if (function_exists('curl_init')) { if ($sfurl) { - while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { - $title=$sfurl->channel[0]->item[$i]->title; + $title = $sfurl->channel[0]->item[$i]->title; if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) { - $newversion=$reg[1]; - $newversionarray=explode('.', $newversion); - $versionarray=explode('.', $version); + $newversion = $reg[1]; + $newversionarray = explode('.', $newversion); + $versionarray = explode('.', $version); //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion; + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; } $i++; } // Show version - print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .''; + print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").''; + print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; } } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").''; + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; } } // Now show link to the changelog print '     -     '; -$version=DOL_VERSION; -if (preg_match('/[a-z]+/i', $version)) $version='develop'; // If version contains text, it is not an official tagged version, so we use the full change log. +$version = DOL_VERSION; +if (preg_match('/[a-z]+/i', $version)) $version = 'develop'; // If version contains text, it is not an official tagged version, so we use the full change log. print ''.$langs->trans("SeeChangeLog").''; print ''."\n"; @@ -155,8 +155,8 @@ print ''."\n"; print ''; print ''; print ''."\n"; -foreach($configfileparameters as $key => $value) +foreach ($configfileparameters as $key => $value) { - $ignore=0; + $ignore = 0; if (empty($ignore)) { @@ -357,7 +357,7 @@ foreach($configfileparameters as $key => $value) if (preg_match('/^\?/', $key) && empty(${$newkey})) { if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) - continue; // We discard parameters starting with ? + continue; // We discard parameters starting with ? } if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue; @@ -378,13 +378,13 @@ foreach($configfileparameters as $key => $value) elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT'); elseif ($newkey == 'dolibarr_main_document_root_alt') { - $tmparray=explode(',', ${$newkey}); - $i=0; - foreach($tmparray as $value2) + $tmparray = explode(',', ${$newkey}); + $i = 0; + foreach ($tmparray as $value2) { if ($i > 0) print ', '; print $value2; - if (! is_readable($value2)) + if (!is_readable($value2)) { $langs->load("errors"); print ' '.img_warning($langs->trans("ErrorCantReadDir", $value2)); @@ -410,7 +410,7 @@ foreach($configfileparameters as $key => $value) print ""; } print "\n"; - $lastkeyshown=$newkey; + $lastkeyshown = $newkey; } } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_SMS_SENDMODE").''; - $text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE]; - if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning(); + $text = $listofmethods[$conf->global->MAIN_SMS_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").' '.img_warning(); print $text; print '
'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMS_FROM; - if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); + if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); print '
'.$langs->trans("Screen").'' print $_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; print '
'.$langs->trans("Session").''; -$i=0; -foreach($_SESSION as $key => $val) +$i = 0; +foreach ($_SESSION as $key => $val) { if ($i > 0) print ', '; if (is_array($val)) print $key.' => array(...)'; @@ -172,7 +172,7 @@ print '
'; // Shmop if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { - $shmoparray=dol_listshmop(); + $shmoparray = dol_listshmop(); print '
'; print ''; @@ -182,7 +182,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S print ''; print ''."\n"; - foreach($shmoparray as $key => $val) + foreach ($shmoparray as $key => $val) { print ''; print ''; @@ -203,15 +203,15 @@ print ''."\n"; print ''."\n"; // Thousands -$thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); -if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method -if ($thousand == 'None') $thousand=''; -print ''."\n"; +$thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); +if ($thousand == 'SeparatorThousand') $thousand = ' '; // ' ' does not work on trans method +if ($thousand == 'None') $thousand = ''; +print ''."\n"; // Decimals -$dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); +$dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); print ''."\n"; // Show results of functions to see if everything works -print ''."\n"; +print ''."\n"; print '\n"; if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) { @@ -220,21 +220,21 @@ if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) } print ''."\n"; // Timezone -$txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'
'."\n"; -$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."
\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php -$txt.=$langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ)?$langs->trans("NotDefined"):$conf->global->MAIN_SERVER_TZ); -print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php +print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print ''."\n"; print ''; print ''; @@ -242,8 +242,8 @@ print ''."\n"; } // Client -$tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; -print ''."\n"; print ''."\n"; print ''."\n"; -$filesystemencoding=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 +$filesystemencoding = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 print ''."\n"; -$tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 -if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows -if (empty($tmp)) $tmp='utf-8'; // By default for other -if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; -print ''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php +$tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 +if (empty($tmp) && !empty($_SERVER["WINDIR"])) $tmp = 'iso-8859-1'; // By default for windows +if (empty($tmp)) $tmp = 'utf-8'; // By default for other +if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; +print ''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php print '
'.$langs->trans("Address").'
'.$key.''.count($val).'
'.$langs->trans("Localisat print '
'.$langs->trans("LanguageBrowserParameter", "HTTP_ACCEPT_LANGUAGE").''.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'
'.$langs->trans("CurrentUserLanguage").''.$langs->getDefaultLang().'
'.$langs->trans("CurrentValueSeparatorThousand").''.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).'
'.$langs->trans("CurrentValueSeparatorThousand").''.($thousand == ' ' ? $langs->transnoentitiesnoconv("Space") : $thousand).'
'.$langs->trans("CurrentValueSeparatorDecimal").''.$dec.'
  => price2num(1233.56+1)'.price2num(1233.56+1, '2').'
  => price2num(1233.56+1)'.price2num(1233.56 + 1, '2').'
  => price2num('."'1".$thousand."234".$dec."56')".price2num("1".$thousand."234".$dec."56", '2')."
  => price(1234.56)'.price(1234.56).'
'.$langs->trans("CurrentTimeZone").''; // Timezone server PHP -$a=getServerTimeZoneInt('now'); -$b=getServerTimeZoneInt('winter'); -$c=getServerTimeZoneInt('summer'); -$daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown'; +$txt = $langs->trans("OSTZ").' (variable system TZ): '.(!empty($_ENV["TZ"]) ? $_ENV["TZ"] : $langs->trans("NotDefined")).'
'."\n"; +$txt .= $langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone") ?ini_get("date.timezone") : $langs->trans("NotDefined")).''."
\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php +$txt .= $langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ) ? $langs->trans("NotDefined") : $conf->global->MAIN_SERVER_TZ); +print '
'.$langs->trans("CurrentTimeZone").''; // Timezone server PHP +$a = getServerTimeZoneInt('now'); +$b = getServerTimeZoneInt('winter'); +$c = getServerTimeZoneInt('summer'); +$daylight = (is_numeric($c) && is_numeric($b)) ?round($c - $b) : 'unknown'; //print $a." ".$b." ".$c." ".$daylight; -$val=($a>=0?'+':'').$a; -$val.=' ('.($a=='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')'; -$val.='       '.getServerTimeZoneString(); -$val.='       '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':($a==$c?yn($daylight):yn(0).($daylight?'     ('.$langs->trans('YesInSummer').')':''))); +$val = ($a >= 0 ? '+' : '').$a; +$val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; +$val .= '       '.getServerTimeZoneString(); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); -print '
  => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now(), 'dayhour', 'tzserver').'
  => dol_print_date(0,"dayhourtext")'.dol_print_date(0, "dayhourtext").'
  => dol_get_first_day(1970,1,false)'.dol_get_first_day(1970, 1, false).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970, 1, false), 'dayhour').')
  => dol_get_first_day(1970,1,true) // Database timezone if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { - print '
'.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base - $sql="SHOW VARIABLES where variable_name = 'system_time_zone'"; + print '
'.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base + $sql = "SHOW VARIABLES where variable_name = 'system_time_zone'"; $resql = $db->query($sql); if ($resql) { @@ -253,25 +253,25 @@ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') print '
'.$langs->trans("ClientTZ").''.($tz?($tz>=0?'+':'').$tz:'').' ('.($tz>=0?'+':'').($tz*60*60).')'; +$tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; +print '
'.$langs->trans("ClientTZ").''.($tz ? ($tz >= 0 ? '+' : '').$tz : '').' ('.($tz >= 0 ? '+' : '').($tz * 60 * 60).')'; print '       '.$_SESSION['dol_tz_string']; print '       '.$langs->trans("DaylingSavingTime").': '; -if ($_SESSION['dol_dst']>0) print yn(1); +if ($_SESSION['dol_dst'] > 0) print yn(1); else print yn(0); -if (! empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')'; +if (!empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']), 'dayhour', 'gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']), 'dayhour', 'gmt').')'; print '
  => '.$langs->trans("ClientHour").''.dol_print_date(dol_now(), 'dayhour', 'tzuser').'
'.$langs->trans("File encoding").' (php.ini unicode.filesystem_encoding)'.$filesystemencoding.'
  => '.$langs->trans("File encoding").''.$tmp.'
  => '.$langs->trans("File encoding").''.$tmp.'
'; print '
'; @@ -280,7 +280,7 @@ print '
'; // Parameters in conf.php file (when a parameter start with ?, it is shown only if defined) -$configfileparameters=array( +$configfileparameters = array( 'dolibarr_main_url_root' => $langs->trans("URLRoot"), '?dolibarr_main_url_root_alt' => $langs->trans("URLRoot").' (alt)', 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), @@ -346,9 +346,9 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; @@ -425,28 +425,28 @@ print ''; print ''; print ''; print ''; -if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled +if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled print "\n"; $sql = "SELECT"; -$sql.= " rowid"; -$sql.= ", ".$db->decrypt('name')." as name"; -$sql.= ", ".$db->decrypt('value')." as value"; -$sql.= ", type"; -$sql.= ", note"; -$sql.= ", entity"; -$sql.= " FROM ".MAIN_DB_PREFIX."const"; +$sql .= " rowid"; +$sql .= ", ".$db->decrypt('name')." as name"; +$sql .= ", ".$db->decrypt('value')." as value"; +$sql .= ", type"; +$sql .= ", note"; +$sql .= ", entity"; +$sql .= " FROM ".MAIN_DB_PREFIX."const"; if (empty($conf->multicompany->enabled)) { // If no multicompany mode, admins can see global and their constantes - $sql.= " WHERE entity IN (0,".$conf->entity.")"; + $sql .= " WHERE entity IN (0,".$conf->entity.")"; } else { // If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities. - if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; + if ($user->entity) $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; } -$sql.= " ORDER BY entity, name ASC"; +$sql .= " ORDER BY entity, name ASC"; $resql = $db->query($sql); if ($resql) { @@ -460,7 +460,7 @@ if ($resql) print ''; print ''."\n"; print ''."\n"; - if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled + if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled print "\n"; $i++; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index cdb9e7dfcea..06003068bb2 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "user", "install")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); /* @@ -49,7 +49,7 @@ print load_fiche_titre($langs->trans("SummarySystem"), '', 'title_setup'); print '
'.$langs->trans("Parameters").' '.$langs->trans("Database").''.$langs->trans("Value").''.$langs->trans("Entity").''.$langs->trans("Entity").'
'.$obj->name.''.dol_escape_htmltag($obj->value).''.$obj->entity.''.$obj->entity.'
'; print "\n"; -$dolversion=version_dolibarr(); +$dolversion = version_dolibarr(); print "\n"; print '
Dolibarr
".$langs->trans("Version")."".$dolversion."
'; @@ -57,7 +57,7 @@ print "
\n"; print ''; print "\n"; -$osversion=version_os(); +$osversion = version_os(); print "\n"; print '
".$langs->trans("OS")."
".$langs->trans("Version")."".$osversion."
'; @@ -66,7 +66,7 @@ print "
\n"; // Serveur web print ''; print "\n"; -$apacheversion=version_webserver(); +$apacheversion = version_webserver(); print "\n"; print '
".$langs->trans("WebServer")."
".$langs->trans("Version")."".$apacheversion."
'; @@ -75,7 +75,7 @@ print "
\n"; // Php print ''; print "\n"; -$phpversion=version_php(); +$phpversion = version_php(); print "\n"; print "\n"; print '
".$langs->trans("PHP")."
".$langs->trans("Version")."".$phpversion."
".$langs->trans("PhpWebLink")."".php_sapi_name()."
'; @@ -85,15 +85,15 @@ print "
\n"; // Database print ''; print "\n"; -$dblabel=$db::LABEL; -$dbversion=$db->getVersion(); -print "\n"; +$dblabel = $db::LABEL; +$dbversion = $db->getVersion(); +print "\n"; print '
".$langs->trans("Database")."
".$langs->trans("Version")."" .$dblabel." ".$dbversion."
".$langs->trans("Version")."".$dblabel." ".$dbversion."
'; // Add checks on database options if ($db->type == 'pgsql') { // Check option standard_conforming_strings is on - $paramarray=$db->getServerParametersValues('standard_conforming_strings'); + $paramarray = $db->getServerParametersValues('standard_conforming_strings'); // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) // { // $langs->load("errors"); @@ -104,8 +104,8 @@ print '
'; // Browser print ''; print "\n"; -print "\n"; -print "\n"; +print "\n"; +print "\n"; print '
".$langs->trans("Browser")."
".$langs->trans("UserAgent")."" .$_SERVER["HTTP_USER_AGENT"]."
".$langs->trans("Smartphone")."".(($conf->browser->layout != 'phone')?$langs->trans("No"):$langs->trans("Yes"))."
".$langs->trans("UserAgent")."".$_SERVER["HTTP_USER_AGENT"]."
".$langs->trans("Smartphone")."".(($conf->browser->layout != 'phone') ? $langs->trans("No") : $langs->trans("Yes"))."
'; print '
'; diff --git a/htdocs/admin/system/web.php b/htdocs/admin/system/web.php index 114a251c8f3..1fb98a3b42f 100644 --- a/htdocs/admin/system/web.php +++ b/htdocs/admin/system/web.php @@ -48,20 +48,20 @@ print '
'; print ''; print '\n"; print '\n"; -print '\n"; +print '\n"; print '\n"; -print '\n"; +print '\n"; print '\n"; -print '\n"; +print '\n"; // Web user group by default -$labeluser=dol_getwebuser('user'); -$labelgroup=dol_getwebuser('group'); +$labeluser = dol_getwebuser('user'); +$labelgroup = dol_getwebuser('group'); if ($labeluser && $labelgroup) { print '\n"; } // Web user group real (detected by 'id' external command) -$arrayout=array(); $varout=0; +$arrayout = array(); $varout = 0; exec('id', $arrayout, $varout); if (empty($varout)) // Test command is ok. Work only on Linux OS. { diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index fa6a558e444..98d77d47118 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -74,7 +74,7 @@ if ($action == 'updateMask') { dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); if (!empty($notification_email)) { @@ -177,7 +177,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); @@ -186,7 +186,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketSetupDictionaries") . ' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
'; +print ''.$langs->trans("TicketSetupDictionaries").' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
'; dol_fiche_end(); @@ -199,17 +199,17 @@ print load_fiche_titre($langs->trans("TicketNumberingModules")); print '
'.$langs->trans("Parameter")."".$langs->trans("Value")."
'.$langs->trans("Version")."".$_SERVER["SERVER_SOFTWARE"]."
'.$langs->trans("VirtualServerName")."" . $_SERVER["SERVER_NAME"] . "
'.$langs->trans("VirtualServerName")."".$_SERVER["SERVER_NAME"]."
'.$langs->trans("IP")."".$_SERVER["SERVER_ADDR"]."
'.$langs->trans("Port")."" . $_SERVER["SERVER_PORT"] . "
'.$langs->trans("Port")."".$_SERVER["SERVER_PORT"]."
'.$langs->trans("DocumentRootServer")."".$_SERVER["DOCUMENT_ROOT"]."
'.$langs->trans("DataRootServer")."" . DOL_DATA_ROOT . "
'.$langs->trans("DataRootServer")."".DOL_DATA_ROOT."
'.$langs->trans("WebUserGroup")." (env vars)".$labeluser.'/'.$labelgroup."
'; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print "\n"; clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir . "core/modules/ticket/"); + $dir = dol_buildpath($reldir."core/modules/ticket/"); if (is_dir($dir)) { $handle = opendir($dir); @@ -219,7 +219,7 @@ foreach ($dirmodels as $reldir) { $file = $reg[1]; $classname = substr($file, 4); - include_once $dir . $file . '.php'; + include_once $dir.$file.'.php'; $module = new $file; @@ -233,7 +233,7 @@ foreach ($dirmodels as $reldir) { } if ($module->isEnabled()) { - print ''; @@ -241,20 +241,20 @@ foreach ($dirmodels as $reldir) { print '' . "\n"; + print ''."\n"; print ''; @@ -263,14 +263,14 @@ foreach ($dirmodels as $reldir) { // Info $htmltooltip = ''; - $htmltooltip .= '' . $langs->trans("Version") . ': ' . $module->getVersion() . '
'; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $ticket); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= '' . $langs->trans("NextValue") . ': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - $htmltooltip .= $nextval . '
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip .= $langs->trans($module->error) . '
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -290,8 +290,8 @@ foreach ($dirmodels as $reldir) { print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Activated") . '' . $langs->trans("ShortInfo") . ''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Activated").''.$langs->trans("ShortInfo").'
' . $module->name . "\n"; + print '
'.$module->name."\n"; print $module->info(); print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - print '
' . $langs->trans($tmp) . '
'; + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } - print '
'; - if ($conf->global->TICKET_ADDON == 'mod_' . $classname) { + if ($conf->global->TICKET_ADDON == 'mod_'.$classname) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } print '

'; if (!$conf->use_javascript_ajax) { - print ''; - print ''; + print ''; + print ''; print ''; } @@ -299,7 +299,7 @@ print load_fiche_titre($langs->trans("TicketParams")); print ''; print ''; -print ''; +print ''; print ''; print ''; print "\n"; @@ -339,7 +339,7 @@ print ''; // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; + print ''; print ''; }*/ // Auto assign ticket at user who created it -print ''; +print ''; print '"; print ""; - $i=0; + $i = 0; while ($i < $num) { diff --git a/htdocs/core/lib/doleditor.lib.php b/htdocs/core/lib/doleditor.lib.php index 2cffa7a2b9d..df9e3d94619 100644 --- a/htdocs/core/lib/doleditor.lib.php +++ b/htdocs/core/lib/doleditor.lib.php @@ -33,39 +33,39 @@ */ function show_skin($fuser, $edit = 0) { - global $conf,$langs,$db; + global $conf, $langs, $db; global $bc; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); - $dirskins=array('/includes/ckeditor/ckeditor/skins'); - if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application + $dirskins = array('/includes/ckeditor/ckeditor/skins'); + if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application { - foreach($conf->modules_parts['theme'] as $reldir) + foreach ($conf->modules_parts['theme'] as $reldir) { - $dirskins=array_merge($dirskins, (array) ($reldir.'theme')); + $dirskins = array_merge($dirskins, (array) ($reldir.'theme')); } } - $dirskins=array_unique($dirskins); + $dirskins = array_unique($dirskins); // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme') - $selected_theme=''; - if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme='moono-lisa'; - else $selected_theme=$conf->global->FCKEDITOR_SKIN; + $selected_theme = ''; + if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme = 'moono-lisa'; + else $selected_theme = $conf->global->FCKEDITOR_SKIN; - $colspan=2; + $colspan = 2; - $thumbsbyrow=6; + $thumbsbyrow = 6; print '
' . $langs->trans("Parameter") . ''.$langs->trans("Parameter").'
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -377,7 +377,7 @@ print '
' . $langs->trans("TicketsAutoAssignTicket") . '
'.$langs->trans("TicketsAutoAssignTicket").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); @@ -402,17 +402,17 @@ print load_fiche_titre($langs->trans("Notification")); print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; -print ''; +print ''; print "\n"; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print ''; - print ''; + print ''; print "\n"; } @@ -435,18 +435,18 @@ print ''; // @TODO Use module notification instead... // Email de réception des notifications -print ''; +print ''; print ''; +print ''; print ''; print ''; // Email d'envoi des notifications -print ''; +print ''; print ''; +print ''; print ''; @@ -454,9 +454,9 @@ print ''; // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''; @@ -466,9 +466,9 @@ print ''; // Texte de signature $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''; @@ -479,7 +479,7 @@ print ''; print '
' . $langs->trans("Email") . ''.$langs->trans("Email").'
' . $langs->trans("TicketCkEditorEmailNotActivated") . '
'.$langs->trans("TicketCkEditorEmailNotActivated").'
' . $langs->trans("TicketEmailNotificationTo") . '
'.$langs->trans("TicketEmailNotificationTo").''; -print ''; print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help'); print '
' . $langs->trans("TicketEmailNotificationFrom") . '
'.$langs->trans("TicketEmailNotificationFrom").''; -print ''; print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; +print '
'.$langs->trans("TicketMessageMailIntroLabelAdmin").''; print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; +print '
'.$langs->trans("TicketMessageMailSignatureLabelAdmin").''; print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
'; print '
'; -print ''; +print ''; print '
'; print ''; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index d6ab0d3830e..d216252c329 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -55,7 +55,7 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') } if ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); if (!empty($topic_interface)) { @@ -158,7 +158,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); @@ -167,7 +167,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; +print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; dol_fiche_end(); @@ -176,32 +176,32 @@ $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Button off, click to enable - $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml.=''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml.=''; - $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml.=''; + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print $enabledisablehtml; -print ''; +print ''; print '

'; -if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { if (empty($conf->use_javascript_ajax)) { - print '
'; - print ''; + print ''; + print ''; print ''; } print ''; - print ''; + print ''; print ''; print ''; // Check if email exists - print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; } @@ -290,25 +290,25 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
' . $langs->trans("Parameters") . '
'.$langs->trans("Parameters").''; print ''; @@ -209,7 +209,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
' . $langs->trans("TicketsEmailMustExist") . '
'.$langs->trans("TicketsEmailMustExist").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); @@ -242,7 +242,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) }*/ // Show logo for company - print '
' . $langs->trans("TicketsShowCompanyLogo") . '
'.$langs->trans("TicketsShowCompanyLogo").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); @@ -259,7 +259,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -275,7 +275,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) } if (!$conf->use_javascript_ajax) { - print '
'; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print "\n"; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print ''; - print ''; + print ''; print "\n"; } // Interface topic $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; - print ''; + print ''; print ''; print ''; @@ -328,9 +328,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte d'aide à la saisie du message $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); - print ''; @@ -339,7 +339,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; // Activate email creation to user - print ''; + print ''; print ''; @@ -367,9 +367,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Url public interface $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print ''; + print ''; print ''; print '
' . $langs->trans("Parameter") . ''.$langs->trans("Parameter").'
' . $langs->trans("TicketCkEditorEmailNotActivated") . '
'.$langs->trans("TicketCkEditorEmailNotActivated").'
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; + print '
'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); @@ -316,9 +316,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte d'accueil homepage $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); - print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; + print '
'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); $doleditor->Create(); print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; + print '
'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); $doleditor->Create(); print '
' . $langs->trans("TicketsDisableCustomerEmail") . '
'.$langs->trans("TicketsDisableCustomerEmail").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); @@ -355,9 +355,9 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Texte de création d'un ticket $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); - print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; + print '
'.$langs->trans("TicketNewEmailBodyLabel").''; print ''; - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); $doleditor->Create(); print '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print '
'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); @@ -377,7 +377,7 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
'; - print '
'; + print '
'; print '
'; } diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index b72941cd6de..31995f2d90e 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -34,18 +34,18 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; // Load translation files required by the page $langs->loadLangs(array('errors', 'admin', 'companies', 'website')); -$action=GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$rowid=GETPOST('rowid', 'alpha'); +$rowid = GETPOST('rowid', 'alpha'); if (!$user->admin) accessforbidden(); $status = 1; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -57,7 +57,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); -$arrayofparameters=array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200')); +$arrayofparameters = array('WEBSITE_USE_WEBSITE_ACCOUNTS'=>array('css'=>'minwidth200')); /* @@ -72,16 +72,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); llxHeader('', $langs->trans("WebsiteSetup")); -$titre=$langs->trans("WebsiteSetup"); -$linkback=''.$langs->trans("BackToModuleList").''; +$titre = $langs->trans("WebsiteSetup"); +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($titre, $linkback, 'title_setup'); // Onglets -$head=array(); +$head = array(); $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/website.php"; @@ -106,11 +106,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; @@ -127,11 +127,11 @@ else print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
'.$conf->global->$key.'
'; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index cb9e61e9da1..81899fee0f0 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -28,9 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals","receptions")); +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposals", "receptions")); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); @@ -41,7 +41,7 @@ $action = GETPOST('action', 'alpha'); if (preg_match('/set(.*)/', $action, $reg)) { - if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) + if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -49,7 +49,7 @@ if (preg_match('/set(.*)/', $action, $reg)) if (preg_match('/del(.*)/', $action, $reg)) { - if (! dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) + if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -62,7 +62,7 @@ if (preg_match('/del(.*)/', $action, $reg)) llxHeader('', $langs->trans("WorkflowSetup"), ''); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup'); print ''.$langs->trans("WorkflowDesc").'
'; @@ -72,29 +72,29 @@ print "
"; clearstatcache(); -$workflowcodes=array( +$workflowcodes = array( // Automatic creation 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), 'separator1'=>array('family'=>'separator', 'position'=>25), // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''), // Automatic classification of order 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. 'separator2'=>array('family'=>'separator', 'position'=>50), // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal', 'warning'=>''), // Automatic classification supplier order - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order', 'warning'=>''), //Automatic classification reception 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'), ); -if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) +if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { - foreach($conf->modules_parts['workflow'] as $workflow) + foreach ($conf->modules_parts['workflow'] as $workflow) { $workflowcodes = array_merge($workflowcodes, $workflow); } @@ -103,16 +103,16 @@ if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts[' // Sort on position $workflowcodes = dol_sort_array($workflowcodes, 'position'); -$nbqualified=0; -$oldfamily=''; +$nbqualified = 0; +$oldfamily = ''; print ''."\n"; -foreach($workflowcodes as $key => $params) +foreach ($workflowcodes as $key => $params) { - $picto=$params['picto']; - $enabled=$params['enabled']; - $family=$params['family']; + $picto = $params['picto']; + $enabled = $params['enabled']; + $family = $params['family']; if ($family == 'separator') { @@ -122,7 +122,7 @@ foreach($workflowcodes as $key => $params) continue; } - if (! verifCond($enabled)) continue; + if (!verifCond($enabled)) continue; $nbqualified++; @@ -156,20 +156,20 @@ foreach($workflowcodes as $key => $params) print "\n"; print "\n"; print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; @@ -601,8 +601,8 @@ if ($rowid > 0) print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -615,17 +615,17 @@ if ($rowid > 0) if (empty($reshook)) { print '

".img_object('', $picto).$langs->trans('desc'.$key); - if (! empty($params['warning'])) + if (!empty($params['warning'])) { $langs->load("errors"); print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); } print "'; - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff($key); } else { - if (! empty($conf->global->$key)) + if (!empty($conf->global->$key)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index f43093d0936..1aee94fb715 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -24,7 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; global $langs, $user; @@ -32,13 +32,13 @@ global $langs, $user; $langs->loadLangs(array("admin", "assets")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); +$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); /* @@ -54,7 +54,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; llxHeader('', $langs->trans("AssetsSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); @@ -72,11 +72,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; @@ -93,11 +93,11 @@ else print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
'.$conf->global->$key.'
'; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index db8dfb60a2b..70191b5eb28 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->load("assets"); @@ -40,25 +40,25 @@ $backtopage = GETPOST('backtopage', 'alpha'); $type = GETPOST('type', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder="DESC"; } -if (! $sortfield) { $sortfield="a.label"; } +if (!$sortorder) { $sortorder = "DESC"; } +if (!$sortfield) { $sortfield = "a.label"; } -$label=GETPOST("label", "alpha"); -$accountancy_code_asset=GETPOST('accountancy_code_asset', 'string'); -$accountancy_code_depreciation_asset=GETPOST('accountancy_code_depreciation_asset', 'string'); -$accountancy_code_depreciation_expense=GETPOST('accountancy_code_depreciation_expense', 'string'); -$comment=GETPOST('comment', 'string'); +$label = GETPOST("label", "alpha"); +$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string'); +$accountancy_code_depreciation_asset = GETPOST('accountancy_code_depreciation_asset', 'string'); +$accountancy_code_depreciation_expense = GETPOST('accountancy_code_depreciation_expense', 'string'); +$comment = GETPOST('comment', 'string'); // Security check -$result=restrictedArea($user, 'asset', $rowid, 'asset_type'); +$result = restrictedArea($user, 'asset', $rowid, 'asset_type'); $object = new AssetType($db); @@ -69,13 +69,13 @@ $extrafields->fetch_name_optionals_label($object->table_element); 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 { - $type=""; - $sall=""; + $type = ""; + $sall = ""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('assettypecard','globalcard')); +$hookmanager->initHooks(array('assettypecard', 'globalcard')); /* @@ -83,9 +83,9 @@ $hookmanager->initHooks(array('assettypecard','globalcard')); */ if ($cancel) { - $action=''; + $action = ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -94,11 +94,11 @@ if ($cancel) { if ($action == 'add' && $user->rights->asset->write) { - $object->label = trim($label); - $object->accountancy_code_asset = trim($accountancy_code_asset); - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); - $object->note = trim($comment); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -121,9 +121,9 @@ if ($action == 'add' && $user->rights->asset->write) } } - if (! $error) + if (!$error) { - $id=$object->create($user); + $id = $object->create($user); if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); @@ -147,19 +147,19 @@ if ($action == 'update' && $user->rights->asset->write) $object->oldcopy = clone $object; - $object->label = trim($label); - $object->accountancy_code_asset = trim($accountancy_code_asset); - $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); - $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); - $object->note = trim($comment); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - $ret=$object->update($user); + $ret = $object->update($user); - if ($ret >= 0 && ! count($object->errors)) + if ($ret >= 0 && !count($object->errors)) { setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); } @@ -175,7 +175,7 @@ if ($action == 'update' && $user->rights->asset->write) if ($action == 'confirm_delete' && $user->rights->asset->write) { $object->fetch($rowid); - $res=$object->delete(); + $res = $object->delete(); if ($res > 0) { @@ -186,7 +186,7 @@ if ($action == 'confirm_delete' && $user->rights->asset->write) else { setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); - $action=''; + $action = ''; } } @@ -195,20 +195,20 @@ if ($action == 'confirm_delete' && $user->rights->asset->write) * View */ -$form=new Form($db); +$form = new Form($db); -$helpurl=''; +$helpurl = ''; llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl); // List of asset type -if (! $rowid && $action != 'create' && $action != 'edit') +if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('asset_type').")"; $result = $db->query($sql); if ($result) @@ -220,12 +220,12 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->asset->configurer) { - $newcardbutton=''.$langs->trans('NewAssetType').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton = ''.$langs->trans('NewAssetType').''; + $newcardbutton .= ''; + $newcardbutton .= ''; } print '
'; @@ -242,7 +242,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; print ''; print ''; @@ -271,7 +271,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_asset print ''; @@ -390,8 +390,8 @@ if ($action == 'create') print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -438,11 +438,11 @@ if ($rowid > 0) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref asset type - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); - $morehtmlref.='
'; + $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->asset->write, 'string', '', null, null, '', 1); + $morehtmlref .= '
'; dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -455,7 +455,7 @@ if ($rowid > 0) 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("Ref").''.dol_escape_htmltag($objp->label).''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objp->accountancy_code_asset, 1); @@ -283,7 +283,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $objp->accountancy_code_depreciation_asset, 1); @@ -295,7 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $objp->accountancy_code_depreciation_expense, 1); @@ -333,7 +333,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') if ($action == 'create') { $object = new AssetType($db); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); print load_fiche_titre($langs->trans("NewAssetType")); @@ -348,7 +348,7 @@ if ($action == 'create') print '
'.$langs->trans("Label").'
'.$langs->trans("AccountancyCodeAsset").'
'; print $langs->trans("AccountancyCodeAsset"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code_asset, 1); @@ -471,7 +471,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationAsset"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount2 = new AccountingAccount($db); $accountingaccount2->fetch('', $object->accountancy_code_depreciation_asset, 1); @@ -487,7 +487,7 @@ if ($rowid > 0) print ''; print $langs->trans("AccountancyCodeDepreciationExpense"); print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { $accountingaccount3 = new AccountingAccount($db); $accountingaccount3->fetch('', $object->accountancy_code_depreciation_expense, 1); @@ -503,7 +503,7 @@ if ($rowid > 0) print nl2br($object->note)."
'; print '
'; @@ -542,7 +542,7 @@ if ($rowid > 0) $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); $head = asset_type_prepare_head($object); @@ -559,7 +559,7 @@ if ($rowid > 0) print '
'.$langs->trans("Label").'
'.$langs->trans("AccountancyCodeAsset").'
'; - foreach($extrafields->attributes[$object->element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->element]['label'] as $key=>$label) { - if (isset($_POST["options_" . $key])) { - if (is_array($_POST["options_" . $key])) { + if (isset($_POST["options_".$key])) { + if (is_array($_POST["options_".$key])) { // $_POST["options"] is an array but following code expects a comma separated string - $value = implode(",", $_POST["options_" . $key]); + $value = implode(",", $_POST["options_".$key]); } else { - $value = $_POST["options_" . $key]; + $value = $_POST["options_".$key]; } } else { - $value = $adht->array_options["options_" . $key]; + $value = $adht->array_options["options_".$key]; } print ''; - print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $total_ttc += $obj->total_ttc; + $total_ttc += $obj->total_ttc; $total += $obj->total_ht; - $totalam += $obj->am; + $totalam += $obj->am; $i++; } - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -938,8 +938,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } else { - $colspan=6; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
'.$label.''; print $extrafields->showInputField($key, $value); diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index b8fc1f1c1c1..3e3a03e139c 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -26,7 +26,7 @@ // Load Dolibarr environment require '../../main.inc.php'; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/bom.lib.php'; //require_once "../class/myclass.class.php"; @@ -34,15 +34,15 @@ require_once '../lib/bom.lib.php'; $langs->loadLangs(array("admin", "mrp")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -59,7 +59,7 @@ $page_name = "BomSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); @@ -80,11 +80,11 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; @@ -97,16 +97,16 @@ if ($action == 'edit') } else { - if (! empty($arrayofparameters)) + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
'.$conf->global->$key.'
'; diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 1602c02beaa..d66b57deaf3 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // If socid provided by ajax company selector -if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) +if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); @@ -49,7 +49,7 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) $_POST["socid"]=''; + if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity); @@ -62,9 +62,9 @@ if (GETPOST('action', 'alpha') == 'set') dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -80,12 +80,12 @@ if (GETPOST('action', 'alpha') == 'set') * View */ -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans("CashDeskSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup'); print '
'; @@ -95,7 +95,7 @@ print ''; print ''; print ''; -if (! empty($conf->service->enabled)) +if (!empty($conf->service->enabled)) { print ''; print ''; @@ -123,7 +123,7 @@ print ''; -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { print ''; print ''; } -if (! empty($conf->stock->enabled)) +if (!empty($conf->stock->enabled)) { - print ''; // Force warehouse (this is not a default value) + print ''; // Force warehouse (this is not a default value) print ''; - $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK; + $disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK; - print ''; // Force warehouse (this is not a default value) + print ''; // Force warehouse (this is not a default value) print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; - print ''; + print ''; print ''; print ''; $tot_ht += $obj->total_ht; $tot_ttc += $obj->total_ttc; //print "x".$tot_ttc."z".$obj->tot_fttc; - $tot_tobill += ($obj->total_ttc-$obj->tot_fttc); + $tot_tobill += ($obj->total_ttc - $obj->tot_fttc); $i++; } print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -821,32 +821,32 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us /* * Unpaid customers invoices */ -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $facstatic=new Facture($db); + $facstatic = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; - $sql.= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; - $sql.= " ORDER BY f.datef ASC, f.ref ASC"; + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; + $sql .= " ORDER BY f.datef ASC, f.ref ASC"; $resql = $db->query($sql); if ($resql) @@ -858,7 +858,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'.$langs->trans("CashDeskThirdParty print ''; print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0); print '
'.$langs->trans("CashDeskBankAccountForSell").''; @@ -143,9 +143,9 @@ if (! empty($conf->banque->enabled)) print '
'.$langs->trans("CashDeskDoNotDecreaseStock").'
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); @@ -160,12 +160,12 @@ if (! empty($conf->stock->enabled)) } print '
'.$langs->trans("CashDeskIdWareHouse").'
'.$langs->trans("CashDeskIdWareHouse").''; - if (! $disabled) + if (!$disabled) { print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled); print ' ('.$langs->trans("Create").')'; @@ -178,7 +178,7 @@ if (! empty($conf->stock->enabled)) } // Use Dolibarr Receipt Printer -if (! empty($conf->receiptprinter->enabled)) +if (!empty($conf->receiptprinter->enabled)) { print '
'; print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index c898fef8be1..56363870dd7 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -41,11 +41,11 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $type = GETPOST('type', 'aZ09'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($id == "") { @@ -74,7 +74,7 @@ if ($cancel == $langs->trans("Cancel")) // Validation de l'ajout if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && -($user->rights->categorie->creer )) +($user->rights->categorie->creer)) { $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -92,7 +92,7 @@ $cancel != $langs->trans("Cancel") && if (!$error) { if (empty($libelle)) { $error++; - $object->errors[] = $langs->trans('Language_' . $forcelangprod) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); } if (!$error) { @@ -129,15 +129,15 @@ $cancel != $langs->trans("Cancel") && foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet { - $libelle = GETPOST('libelle-'. $key, 'alpha'); - $desc = GETPOST('desc-' . $key); + $libelle = GETPOST('libelle-'.$key, 'alpha'); + $desc = GETPOST('desc-'.$key); if (empty($libelle)) { $error++; - $object->errors[] = $langs->trans('Language_' . $key) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); } - if ( $key == $current_lang ) { + if ($key == $current_lang) { $object->label = $libelle; $object->description = dol_htmlcleanlastbr($desc); } else { @@ -169,24 +169,24 @@ $result = $object->fetch($id, $ref); llxHeader("", "", $langs->trans("Translation")); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); $formother = new FormOther($db); -if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); -elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); -elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); -elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); -elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); -elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); -elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); -else $title=$langs->trans("Category"); +if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); +elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); +elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); +elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); +elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); +elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); +else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -199,15 +199,15 @@ dol_fiche_head($head, 'translation', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->ref = $object->label; -$morehtmlref='
'.$langs->trans("Root").' >> '; +$morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { - $morehtmlref.=$way."
\n"; + $morehtmlref .= $way."
\n"; } -$morehtmlref.='
'; +$morehtmlref .= '
'; -dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); print '
'; @@ -266,9 +266,9 @@ if ($action == 'edit') print ''; print ''; print ''; - print ''; + print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -304,23 +304,23 @@ elseif ($action != 'add') { if ($cnt_trans) print '
'; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); + $s = picto_from_langcode($key); print ''; - print ''; + print ''; print ''; print ''; - if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } print '
'.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'; } } - if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; + if (!$cnt_trans && $action != 'add') print '
'.$langs->trans('NoTranslation').'
'; } @@ -338,14 +338,14 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print '"; print ''; print ''."\n"; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -883,7 +883,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 42c1f191a0a..94e885d53dc 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -22,30 +22,30 @@ * \brief Page to define emailing targets */ -if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); +if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/advtargetemailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/html.formadvtargetemailing.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/mailings/advthirdparties.modules.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/advtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/html.formadvtargetemailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/advthirdparties.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('mails', 'companies')); -if (! empty($conf->categorie->enabled)) { +if (!empty($conf->categorie->enabled)) { $langs->load("categories"); } // Security check -if (! $user->rights->mailing->lire || $user->socid > 0) +if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // 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'); @@ -53,9 +53,9 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) +if (!$sortorder) $sortorder = "ASC"; -if (! $sortfield) +if (!$sortfield) $sortfield = "email"; $id = GETPOST('id', 'int'); @@ -72,7 +72,7 @@ if (GETPOST('button_removefilter_x', 'alpha')) { $search_prenom = ''; $search_email = ''; } -$array_query = array (); +$array_query = array(); $object = new Mailing($db); $advTarget = new AdvanceTargetingMailing($db); @@ -90,7 +90,7 @@ if ($result < 0) } else { - if (! empty($advTarget->id)) { + if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } } @@ -101,12 +101,12 @@ else */ if ($action == 'loadfilter') { - if (! empty($template_id)) { + if (!empty($template_id)) { $result = $advTarget->fetch($template_id); if ($result < 0) { setEventMessages($advTarget->error, $advTarget->errors, 'errors'); } else { - if (! empty($advTarget->id)) { + if (!empty($advTarget->id)) { $array_query = json_decode($advTarget->filtervalue, true); } } @@ -116,7 +116,7 @@ if ($action == 'loadfilter') { if ($action == 'add') { $user_contact_query = false; - $array_query = array (); + $array_query = array(); // Get extra fields @@ -125,17 +125,17 @@ if ($action == 'add') { if (preg_match("/^options_.*(?contact_lines) == 0) { - $advTarget->contact_lines = array ( + $advTarget->contact_lines = array( 0 ); } } else { - $advTarget->contact_lines = array (); + $advTarget->contact_lines = array(); } if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { @@ -234,11 +234,11 @@ if ($action == 'add') { if ($result > 0) { $query_temlate_id = ''; - if (! empty($template_id)) { - $query_temlate_id = '&template_id=' . $template_id; + if (!empty($template_id)) { + $query_temlate_id = '&template_id='.$template_id; } setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs'); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id . $query_temlate_id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id.$query_temlate_id); exit(); } if ($result == 0) { @@ -255,7 +255,7 @@ if ($action == 'clear') { $obj = new $classname($db); $obj->clear_target($id); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } @@ -265,28 +265,28 @@ if ($action == 'savefilter' || $action == 'createfilter') { if ($action == 'createfilter' && empty($template_name)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('AdvTgtOrCreateNewFilter')), null, 'errors'); - $error ++; + $error++; } if (empty($error)) { - $array_query = array (); + $array_query = array(); // Get extra fields foreach ($_POST as $key => $value) { if (preg_match("/^options_.*(?error, $advTarget->errors, 'errors'); } - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing_cibles WHERE rowid=" . $rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; $resql = $db->query($sql); if ($resql) { - if (! empty($id)) { + if (!empty($id)) { $classname = "MailingTargets"; $obj = new $classname($db); $obj->update_nb($id); - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit(); } else { header("Location: liste.php"); @@ -421,30 +421,30 @@ if ($object->fetch($id) >= 0) { print '
'.$langs->trans('Translation').''; print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); print '
' . $langs->trans('Label') . '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e4e204c11e3..47feb0e75ae 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -133,13 +133,13 @@ $hookmanager->initHooks(array('agenda')); if (GETPOST("viewlist", 'alpha') || $action == 'show_list') { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -149,13 +149,13 @@ if (GETPOST("viewlist", 'alpha') || $action == 'show_list') if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -163,11 +163,11 @@ if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') exit; } -if ($action =='delete_action') +if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); - $result=$event->delete(); + $result = $event->delete(); } @@ -195,62 +195,62 @@ $parameters = array( $reshook = $hookmanager->executeHooks('beforeAgenda', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); -$form=new Form($db); -$companystatic=new Societe($db); -$contactstatic=new Contact($db); +$form = new Form($db); +$companystatic = new Societe($db); +$contactstatic = new Contact($db); -$now=dol_now(); -$nowarray=dol_getdate($now); -$nowyear=$nowarray['year']; -$nowmonth=$nowarray['mon']; -$nowday=$nowarray['mday']; +$now = dol_now(); +$nowarray = dol_getdate($now); +$nowyear = $nowarray['year']; +$nowmonth = $nowarray['mon']; +$nowday = $nowarray['mday']; -$listofextcals=array(); +$listofextcals = array(); // Define list of external calendars (global admin setup) if (empty($conf->global->AGENDA_DISABLE_EXT)) { - $i=0; - while($i < $MAXAGENDA) + $i = 0; + while ($i < $MAXAGENDA) { $i++; - $source='AGENDA_EXT_SRC'.$i; - $name='AGENDA_EXT_NAME'.$i; - $offsettz='AGENDA_EXT_OFFSETTZ'.$i; - $color='AGENDA_EXT_COLOR'.$i; - $buggedfile='AGENDA_EXT_BUGGEDFILE'.$i; - if (! empty($conf->global->$source) && ! empty($conf->global->$name)) + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (!empty($conf->global->$source) && !empty($conf->global->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[]=array('src'=>$conf->global->$source,'name'=>$conf->global->$name,'offsettz'=>$conf->global->$offsettz,'color'=>$conf->global->$color,'buggedfile'=>(isset($conf->global->buggedfile)?$conf->global->buggedfile:0)); + $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); } } } // Define list of external calendars (user setup) if (empty($user->conf->AGENDA_DISABLE_EXT)) { - $i=0; - while($i < $MAXAGENDA) + $i = 0; + while ($i < $MAXAGENDA) { $i++; - $source='AGENDA_EXT_SRC_'.$user->id.'_'.$i; - $name='AGENDA_EXT_NAME_'.$user->id.'_'.$i; - $offsettz='AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; - $color='AGENDA_EXT_COLOR_'.$user->id.'_'.$i; - $enabled='AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; - $buggedfile='AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; - if (! empty($user->conf->$source) && ! empty($user->conf->$name)) + $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i; + $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i; + $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; + if (!empty($user->conf->$source) && !empty($user->conf->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[]=array('src'=>$user->conf->$source,'name'=>$user->conf->$name,'offsettz'=>$user->conf->$offsettz,'color'=>$user->conf->$color,'buggedfile'=>(isset($user->conf->buggedfile)?$user->conf->buggedfile:0)); + $listofextcals[] = array('src'=>$user->conf->$source, 'name'=>$user->conf->$name, 'offsettz'=>$user->conf->$offsettz, 'color'=>$user->conf->$color, 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)); } } } -if (empty($action) || $action=='show_month') +if (empty($action) || $action == 'show_month') { $prev = dol_get_prev_month($month, $year); $prev_year = $prev['year']; @@ -259,26 +259,26 @@ if (empty($action) || $action=='show_month') $next_year = $next['year']; $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) - $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true))+2; // date('w') is 0 fo sunday - $tmpday+=((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)-1); - if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. + $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday + $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); + if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow=dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month+$tmpday, $prev_year); - $next_day=7 - ($max_day_in_month+1-$tmpday) % 7; - if ($next_day < 6) $next_day+=7; - $lastdaytoshow=dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); + $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; + if ($next_day < 6) $next_day += 7; + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } -if ($action=='show_week') +if ($action == 'show_week') { $prev = dol_get_first_day_week($day, $month, $year); $prev_year = $prev['prev_year']; $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; $first_day = $prev['first_day']; - $first_month= $prev['first_month']; + $first_month = $prev['first_month']; $first_year = $prev['first_year']; $week = $prev['week']; @@ -290,8 +290,8 @@ if ($action=='show_week') $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'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); @@ -309,79 +309,79 @@ if ($action == 'show_day') $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow=dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); - $lastdaytoshow=dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); } //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; //print dol_print_date($firstdaytoshow,'day'); //print dol_print_date($lastdaytoshow,'day'); -$title=$langs->trans("DoneAndToDoActions"); -if ($status == 'done') $title=$langs->trans("DoneActions"); -if ($status == 'todo') $title=$langs->trans("ToDoActions"); +$title = $langs->trans("DoneAndToDoActions"); +if ($status == 'done') $title = $langs->trans("DoneActions"); +if ($status == 'todo') $title = $langs->trans("ToDoActions"); -$param=''; +$param = ''; if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { - if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); - } else $param.="&search_actioncode=".urlencode($actioncode); + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); -if ($filter) $param.="&search_filter=".urlencode($filter); -if ($filtert) $param.="&search_filtert=".urlencode($filtert); -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); -if ($socid) $param.="&search_socid=".urlencode($socid); -if ($showbirthday) $param.="&search_showbirthday=1"; -if ($pid) $param.="&search_projectid=".urlencode($pid); -if ($type) $param.="&search_type=".urlencode($type); -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param.='&action='.urlencode($action); -$param.="&maxprint=".urlencode($maxprint); +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param .= '&action='.urlencode($action); +$param .= "&maxprint=".urlencode($maxprint); // Show navigation bar -if (empty($action) || $action=='show_month') +if (empty($action) || $action == 'show_month') { - $nav ="  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); - $nav.=" \n"; - $nav.="   \n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendar'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendar'; } -if ($action=='show_week') +if ($action == 'show_week') { - $nav ="trans("Previous"))."\">  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; - $nav.=" \n"; - $nav.="   trans("Next"))."\">\n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendarweek'; + $nav = "trans("Previous"))."\">  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; + $nav .= " \n"; + $nav .= "   trans("Next"))."\">\n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarweek'; } -if ($action=='show_day') +if ($action == 'show_day') { - $nav ="  \n"; - $nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); - $nav.=" \n"; - $nav.="   \n"; - $nav.="   (".$langs->trans("Today").")"; - $picto='calendarday'; + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarday'; } // Must be after the nav definition -$param.='&year='.$year.'&month='.$month.($day?'&day='.$day:''); +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); //print 'x'.$param; -$tabactive=''; -if ($action == 'show_month') $tabactive='cardmonth'; -if ($action == 'show_week') $tabactive='cardweek'; -if ($action == 'show_day') $tabactive='cardday'; -if ($action == 'show_list') $tabactive='cardlist'; +$tabactive = ''; +if ($action == 'show_month') $tabactive = 'cardmonth'; +if ($action == 'show_week') $tabactive = 'cardweek'; +if ($action == 'show_day') $tabactive = 'cardday'; +if ($action == 'show_list') $tabactive = 'cardlist'; -$paramnoaction=preg_replace('/action=[a-z_]+/', '', $param); +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $head = calendars_prepare_head($paramnoaction); @@ -395,66 +395,66 @@ dol_fiche_end(); // Define the legend/list of calendard to show -$s=''; $link=''; +$s = ''; $link = ''; -$showextcals=$listofextcals; +$showextcals = $listofextcals; -if (! empty($conf->use_javascript_ajax)) // If javascript on +if (!empty($conf->use_javascript_ajax)) // If javascript on { - $s.="\n".''."\n"; - $s.='' . "\n"; + $s .= '});'."\n"; + $s .= ''."\n"; // Local calendar - $s.='
' . $langs->trans("LocalAgenda").'  
'; + $s .= '
'.$langs->trans("LocalAgenda").'  
'; // External calendars if (is_array($showextcals) && count($showextcals) > 0) { - $s.='' . "\n"; + $s .= ''."\n"; foreach ($showextcals as $val) { $htmlname = md5($val['name']); - $s.='
' . $val['name'] . '  
'; + $s .= '
'.$val['name'].'  
'; } } // Birthdays - $s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; + $s .= '
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters=array(); $object=null; - $reshook=$hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { - $s.= $hookmanager->resPrint; + $s .= $hookmanager->resPrint; } elseif ($reshook > 1) { @@ -463,182 +463,182 @@ if (! empty($conf->use_javascript_ajax)) // If javascript on } else // If javascript off { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday)?1:0), $newparam); - if (! preg_match('/showbirthday=/i', $newparam)) $newparam.='&showbirthday=1'; - $link=''; - if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); - else $link.=$langs->trans("AgendaHideBirthdayEvents"); - $link.=''; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + $link = ''; + if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); + else $link .= $langs->trans("AgendaHideBirthdayEvents"); + $link .= ''; } print load_fiche_titre($s, $link.'     '.$nav, '', 0, 0, 'tablelistofcalendars'); // Load events from database into $eventarray -$eventarray=array(); +$eventarray = array(); $sql = 'SELECT '; -if ($usergroup > 0) $sql.=" DISTINCT"; -$sql.= ' a.id, a.label,'; -$sql.= ' a.datep,'; -$sql.= ' a.datep2,'; -$sql.= ' a.percent,'; -$sql.= ' a.fk_user_author,a.fk_user_action,'; -$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact,'; -$sql.= ' a.fk_element, a.elementtype,'; -$sql.= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +if ($usergroup > 0) $sql .= " DISTINCT"; +$sql .= ' a.id, a.label,'; +$sql .= ' a.datep,'; +$sql .= ' a.datep2,'; +$sql .= ' a.percent,'; +$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; +$sql .= ' a.fk_soc, a.fk_contact,'; +$sql .= ' a.fk_element, a.elementtype,'; +$sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; // We must filter on resource table -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -$sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +$sql .= ' WHERE a.fk_action = ca.id'; +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (! empty($actioncode)) +if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { if (is_array($actioncode)) { - $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; } else { - $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; } } } } -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { // To limit array - $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; // Start 7 days before - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; - $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year)-(60*60*24*7))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year)+(60*60*24*10))."')"; - $sql.= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= ')'; } -if ($type) $sql.= " AND ca.id = ".$type; -if ($status == '0') { $sql.= " AND a.percent = 0"; } -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($type) $sql .= " AND ca.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql.= " AND ("; - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; - $sql.= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date -$sql.= ' ORDER BY datep'; +$sql .= ' ORDER BY datep'; //print $sql; dol_syslog("comm/action/index.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $MAXONSAMEPAGE=10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) - $i=0; + $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) + $i = 0; while ($i < $num && $i < $MAXONSAMEPAGE) { $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } // Create a new object action - $event=new ActionComm($db); - $event->id=$obj->id; + $event = new ActionComm($db); + $event->id = $obj->id; - $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin - $event->datef=$db->jdate($obj->datep2); + $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin + $event->datef = $db->jdate($obj->datep2); //var_dump($obj->datep); //var_dump($event->datep); - $event->type_code=$obj->type_code; - $event->type_label=$obj->type_label; - $event->type_color=$obj->type_color; + $event->type_code = $obj->type_code; + $event->type_label = $obj->type_label; + $event->type_color = $obj->type_color; - $event->libelle=$obj->label; // deprecated - $event->label=$obj->label; - $event->percentage=$obj->percent; - $event->authorid=$obj->fk_user_author; // user id of creator - $event->userownerid=$obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned - $event->priority=$obj->priority; - $event->fulldayevent=$obj->fulldayevent; - $event->location=$obj->location; - $event->transparency=$obj->transparency; - $event->fk_element=$obj->fk_element; - $event->elementtype=$obj->elementtype; + $event->libelle = $obj->label; // deprecated + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->fetch_userassigned(); // This load $event->userassigned + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - $event->thirdparty_id=$obj->fk_soc; - $event->contact_id=$obj->fk_contact; + $event->thirdparty_id = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + $event->date_start_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { - $event->ponctuel=1; + $event->ponctuel = 1; } // Check values @@ -649,27 +649,27 @@ if ($resql) } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); do { //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][]=$event; + $eventarray[$daykey][] = $event; $j++; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; } while ($loop); @@ -689,58 +689,58 @@ if ($showbirthday) { // Add events in array $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; - $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; + $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; if ($action == 'show_day') { - $sql.= ' AND MONTH(birthday) = '.$month; - $sql.= ' AND DAY(birthday) = '.$day; + $sql .= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND DAY(birthday) = '.$day; } else { - $sql.= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND MONTH(birthday) = '.$month; } - $sql.= ' ORDER BY birthday'; + $sql .= ' ORDER BY birthday'; dol_syslog("comm/action/index.php", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $event=new ActionComm($db); - $event->id=$obj->rowid; // We put contact id in action id for birthdays events - $datebirth=dol_stringtotime($obj->birthday, 1); + $event = new ActionComm($db); + $event->id = $obj->rowid; // We put contact id in action id for birthdays events + $datebirth = dol_stringtotime($obj->birthday, 1); //print 'ee'.$obj->birthday.'-'.$datebirth; - $datearray=dol_getdate($datebirth, true); - $event->datep=dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output - $event->datef=$event->datep; - $event->type_code='BIRTHDAY'; - $event->label=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); - $event->percentage=100; - $event->fulldayevent=1; + $datearray = dol_getdate($datebirth, true); + $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output + $event->datef = $event->datep; + $event->type_code = 'BIRTHDAY'; + $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->percentage = 100; + $event->fulldayevent = 1; - $event->date_start_in_calendar=$event->datep; - $event->date_end_in_calendar=$event->datef; - $event->ponctuel=0; + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + $event->ponctuel = 0; // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); - $loop=true; - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); + $loop = true; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); do { - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; } while ($loop); $i++; @@ -756,28 +756,28 @@ if ($showbirthday) if (count($listofextcals)) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; - foreach($listofextcals as $extcal) + foreach ($listofextcals as $extcal) { - $url=$extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics + $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics $namecal = $extcal['name']; $offsettz = $extcal['offsettz']; $colorcal = $extcal['color']; $buggedfile = $extcal['buggedfile']; //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; - $ical=new ICal(); + $ical = new ICal(); $ical->parse($url); // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; - $icalevents=array(); - if (is_array($ical->get_event_list())) $icalevents=array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] - if (is_array($ical->get_freebusy_list())) $icalevents=array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + $icalevents = array(); + if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] - if (count($icalevents)>0) + if (count($icalevents) > 0) { // Duplicate all repeatable events into new entries - $moreicalevents=array(); - foreach($icalevents as $icalevent) + $moreicalevents = array(); + foreach ($icalevents as $icalevent) { if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event { @@ -785,26 +785,26 @@ if (count($listofextcals)) //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); if ($icalevent['DTSTART;VALUE=DATE']) //fullday event { - $datecurstart=dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $datecurend=dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1)-1; // We remove one second to get last second of day + $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day } - elseif (is_array($icalevent['DTSTART']) && ! empty($icalevent['DTSTART']['unixtime'])) + elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { - $datecurstart=$icalevent['DTSTART']['unixtime']; - $datecurend=$icalevent['DTEND']['unixtime']; - if (! empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) + $datecurstart = $icalevent['DTSTART']['unixtime']; + $datecurend = $icalevent['DTEND']['unixtime']; + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) { //var_dump($ical->cal); - $tmpcurstart=$datecurstart; - $tmpcurend=$datecurend; - $tmpdaylightstart=dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; - $tmpdaylightend=dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; + $tmpcurstart = $datecurstart; + $tmpcurend = $datecurend; + $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; + $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); // Edit datecurstart and datecurend - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart-=((int) $ical->cal['DAYLIGHT']['TZOFFSETTO'])*36; - else $datecurstart-=((int) $ical->cal['STANDARD']['TZOFFSETTO'])*36; - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend-=((int) $ical->cal['DAYLIGHT']['TZOFFSETTO'])*36; - else $datecurend-=((int) $ical->cal['STANDARD']['TZOFFSETTO'])*36; + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; } // datecurstart and datecurend are now GMT date //var_dump($datecurstart); var_dump($datecurend); exit; @@ -817,106 +817,106 @@ if (count($listofextcals)) } //print 'xx'.$datecurstart;exit; - $interval=(empty($icalevent['RRULE']['INTERVAL'])?1:$icalevent['RRULE']['INTERVAL']); - $until=empty($icalevent['RRULE']['UNTIL'])?0:dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); - $maxrepeat=empty($icalevent['RRULE']['COUNT'])?0:$icalevent['RRULE']['COUNT']; - if ($until && ($until+($datecurend-$datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show - if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show + $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); + $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); + $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show + if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show - $numofevent=0; + $numofevent = 0; while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { if ($datecurend >= $firstdaytoshow) // We add event { - $newevent=$icalevent; + $newevent = $icalevent; unset($newevent['RRULE']); if ($icalevent['DTSTART;VALUE=DATE']) { - $newevent['DTSTART;VALUE=DATE']=dol_print_date($datecurstart, '%Y%m%d'); - $newevent['DTEND;VALUE=DATE']=dol_print_date($datecurend+1, '%Y%m%d'); + $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); + $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); } else { - $newevent['DTSTART']=$datecurstart; - $newevent['DTEND']=$datecurend; + $newevent['DTSTART'] = $datecurstart; + $newevent['DTEND'] = $datecurend; } - $moreicalevents[]=$newevent; + $moreicalevents[] = $newevent; } // Jump on next occurence $numofevent++; - $savdatecurstart=$datecurstart; - if ($icalevent['RRULE']['FREQ']=='DAILY') + $savdatecurstart = $datecurstart; + if ($icalevent['RRULE']['FREQ'] == 'DAILY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'd'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'd'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); } - if ($icalevent['RRULE']['FREQ']=='WEEKLY') + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'w'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'w'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); } - elseif ($icalevent['RRULE']['FREQ']=='MONTHLY') + elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'm'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'm'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); } - elseif ($icalevent['RRULE']['FREQ']=='YEARLY') + elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { - $datecurstart=dol_time_plus_duree($datecurstart, $interval, 'y'); - $datecurend=dol_time_plus_duree($datecurend, $interval, 'y'); + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); } // Test to avoid infinite loop ($datecurstart must increase) if ($savdatecurstart >= $datecurstart) { dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); - $datecurstart+=3600*24*7; - $datecurend+=3600*24*7; + $datecurstart += 3600 * 24 * 7; + $datecurend += 3600 * 24 * 7; } } } } - $icalevents=array_merge($icalevents, $moreicalevents); + $icalevents = array_merge($icalevents, $moreicalevents); // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray - foreach($icalevents as $icalevent) + foreach ($icalevents as $icalevent) { //var_dump($icalevent); //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; - if (! empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. // Create a new object action - $event=new ActionComm($db); + $event = new ActionComm($db); $addevent = false; if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event { // For full day events, date are also GMT but they wont but converted using tz during output - $datestart=dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $dateend=dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1)-1; // We remove one second to get last second of day + $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day //print 'x'.$datestart.'-'.$dateend;exit; //print dol_print_date($dateend,'dayhour','gmt'); - $event->fulldayevent=1; - $addevent=true; + $event->fulldayevent = 1; + $addevent = true; } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) { - $datestart=$icalevent['DTSTART']; - $dateend=$icalevent['DTEND']; + $datestart = $icalevent['DTSTART']; + $dateend = $icalevent['DTEND']; - $datestart+=+($offsettz * 3600); - $dateend+=+($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); - $addevent=true; + $addevent = true; //var_dump($offsettz); //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) { - $datestart=$icalevent['DTSTART']['unixtime']; - $dateend=$icalevent['DTEND']['unixtime']; + $datestart = $icalevent['DTSTART']['unixtime']; + $dateend = $icalevent['DTEND']['unixtime']; - $datestart+=+($offsettz * 3600); - $dateend+=+($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 @@ -930,38 +930,38 @@ if (count($listofextcals)) $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); - $tmps=-1*$localtzs->getOffset($localdts); - $tmpe=-1*$localtze->getOffset($localdte); - $datestart+=$tmps; - $dateend+=$tmpe; + $tmps = -1 * $localtzs->getOffset($localdts); + $tmpe = -1 * $localtze->getOffset($localdte); + $datestart += $tmps; + $dateend += $tmpe; //var_dump($datestart); } - $addevent=true; + $addevent = true; } if ($addevent) { - $event->id=$icalevent['UID']; - $event->icalname=$namecal; - $event->icalcolor=$colorcal; - $usertime=0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. - $event->datep=$datestart+$usertime; - $event->datef=$dateend+$usertime; - $event->type_code="ICALEVENT"; + $event->id = $icalevent['UID']; + $event->icalname = $namecal; + $event->icalcolor = $colorcal; + $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep = $datestart + $usertime; + $event->datef = $dateend + $usertime; + $event->type_code = "ICALEVENT"; - if($icalevent['SUMMARY']) $event->label=$icalevent['SUMMARY']; - elseif($icalevent['DESCRIPTION']) $event->label=dol_nl2br($icalevent['DESCRIPTION'], 1); + if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; + elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); else $event->label = $langs->trans("ExtSiteNoLabel"); - $event->date_start_in_calendar=$event->datep; + $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { - $event->ponctuel=1; + $event->ponctuel = 1; //print 'x'.$datestart.'-'.$dateend;exit; } @@ -975,26 +975,26 @@ if (count($listofextcals)) } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; + $daycursor = $event->date_start_in_calendar; $annee = date('Y', $daycursor); $mois = date('m', $daycursor); $jour = date('d', $daycursor); // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; + $loop = true; $j = 0; // daykey must be date that represent day box in calendar so must be a user time - $daykey=dol_mktime(0, 0, 0, $mois, $jour, $annee); - $daykeygmt=dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); do { //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; $daykeygmt+=60*60*24; // Add one day - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop=false; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; } while ($loop); } @@ -1007,28 +1007,28 @@ if (count($listofextcals)) // Complete $eventarray with events coming from external module -$parameters=array(); $object=null; -$reshook=$hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); -if (! empty($hookmanager->resArray['eventarray'])) { +$parameters = array(); $object = null; +$reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action); +if (!empty($hookmanager->resArray['eventarray'])) { foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { if (!isset($eventarray[$keyDate])) { - $eventarray[$keyDate]=array(); + $eventarray[$keyDate] = array(); } - $eventarray[$keyDate]=array_merge($eventarray[$keyDate], $events); + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); } } // Sort events -foreach($eventarray as $keyDate => &$dateeventarray) +foreach ($eventarray as $keyDate => &$dateeventarray) { usort($dateeventarray, 'sort_events_by_date'); } -$maxnbofchar=0; -$cachethirdparties=array(); -$cachecontacts=array(); -$cacheusers=array(); +$maxnbofchar = 0; +$cachethirdparties = array(); +$cachecontacts = array(); +$cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -1036,34 +1036,34 @@ if (is_readable($color_file)) { include_once $color_file; } -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); if (empty($action) || $action == 'show_month') // View by month { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam.='&viewcal=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewcal=1'; print '
'; print ''; print ' '; - $i=0; + $i = 0; while ($i < 7) { print ' '."\n"; - $todayarray=dol_getdate($now, 'fast'); - $todaytms=dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); + $todayarray = dol_getdate($now, 'fast'); + $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) //var_dump($eventarray); - for ($iter_week = 0; $iter_week < 6 ; $iter_week++) + for ($iter_week = 0; $iter_week < 6; $iter_week++) { echo " \n"; for ($iter_day = 0; $iter_day < 7; $iter_day++) @@ -1085,8 +1085,8 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days before the beginning of the current month (previous month) */ if ($tmpday <= 0) { - $style='cal_other_month cal_past'; - if ($iter_day == 6) $style.=' cal_other_month_right'; + $style = 'cal_other_month cal_past'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' \n"; @@ -1095,12 +1095,12 @@ if (empty($action) || $action == 'show_month') // View by month elseif ($tmpday <= $max_day_in_month) { $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_current_month_right'; - $today=0; - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; - if ($today) $style='cal_today'; - if ($curtime < $todaytms) $style.=' cal_past'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_current_month_right'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($today) $style = 'cal_today'; + if ($curtime < $todaytms) $style .= ' cal_past'; //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); echo ' \n"; @@ -1124,28 +1124,28 @@ if (empty($action) || $action == 'show_month') // View by month print ''; print ''; - print '' ; + print ''; } elseif ($action == 'show_week') // View by week { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); - $newparam=preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam.='&viewweek=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewweek=1'; print '
'; print '
'; - $numdayinweek=(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7); - if (! empty($conf->dol_optimize_smallscreen)) + $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); + if (!empty($conf->dol_optimize_smallscreen)) { - $labelshort=array(0=>'SundayMin',1=>'MondayMin',2=>'TuesdayMin',3=>'WednesdayMin',4=>'ThursdayMin',5=>'FridayMin',6=>'SaturdayMin'); + $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); print $langs->trans($labelshort[$numdayinweek]); } else print $langs->trans("Day".$numdayinweek); @@ -1072,12 +1072,12 @@ if (empty($action) || $action == 'show_month') // View by month } echo '
'; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); @@ -1109,8 +1109,8 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days after the current month (next month) */ else { - $style='cal_other_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; + $style = 'cal_other_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; echo ' '; show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo "
'; print ' '; - $i=0; + $i = 0; while ($i < 7) { - echo ' \n"; + echo ' \n"; $i++; } echo " \n"; @@ -1161,12 +1161,12 @@ elseif ($action == 'show_week') // View by week $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; - $today=0; - $todayarray=dol_getdate($now, 'fast'); - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; - if ($today) $style='cal_today'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today'; echo ' "; print ''; print ''."\n"; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -779,7 +779,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -796,23 +796,23 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) /* * Opened Order */ -if (! empty($conf->commande->enabled) && $user->rights->commande->lire) +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql.= ", s.code_client"; - $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.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.code_client"; + $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.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND (c.fk_statut = ".Commande::STATUS_VALIDATED." or c.fk_statut = ".Commande::STATUS_SHIPMENTONPROCESS.")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY c.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -824,7 +824,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); @@ -1179,24 +1179,24 @@ elseif ($action == 'show_week') // View by week echo ''; echo ''; - echo '' ; + echo ''; } else // View by day { - $newparam=$param; // newparam is for birthday links - $newparam=preg_replace('/action=show_month&?/i', '', $newparam); - $newparam=preg_replace('/action=show_week&?/i', '', $newparam); - $newparam=preg_replace('/viewday=[0-9]+&?/i', '', $newparam); - $newparam.='&viewday=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); + $newparam .= '&viewday=1'; // Code to show just one day - $style='cal_current_month cal_current_month_oneday'; - $today=0; - $todayarray=dol_getdate($now, 'fast'); - if ($todayarray['mday']==$day && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; + $style = 'cal_current_month cal_current_month_oneday'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; //if ($today) $style='cal_today'; - $timestamp=dol_mktime(12, 0, 0, $month, $day, $year); - $arraytimestamp=dol_getdate($timestamp); + $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); + $arraytimestamp = dol_getdate($timestamp); //echo ''; echo '
'; @@ -1221,14 +1221,14 @@ else // View by day $useviewhour = 0; if ($useviewhour) { - 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 - $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-200):660; // Also into index.php file + $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file echo '
'; echo '
'; - $maxnbofchar=80; + $maxnbofchar = 80; $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); $minhour = round($tmp[0], 0); @@ -1242,7 +1242,7 @@ else // View by day while ($i < 24) { echo '
'."\n"; - echo '
'.dol_print_date($i*3600, 'hour', 'gmt').'
'; + echo '
'.dol_print_date($i * 3600, 'hour', 'gmt').'
'; echo '
'; echo "
\n"; echo "
\n"; @@ -1258,7 +1258,7 @@ else // View by day } else { - 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 show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); @@ -1294,7 +1294,7 @@ $db->close(); function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) { global $user, $conf, $langs; - global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form + global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form global $theme_datacolor; global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; @@ -1319,11 +1319,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - print ''; + $hourminsec = '100000'; + print ''; print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; } @@ -1341,11 +1341,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); - $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); - $ymd=sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse=is_array($colorindexused)?count($colorindexused):0; // At first run this is 0, so fist user has 0, next 1, ... + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 + $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... //var_dump($colorindexused); foreach ($eventarray as $daykey => $notused) @@ -1353,117 +1353,117 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $annee = date('Y', $daykey); $mois = date('m', $daykey); $jour = date('d', $daykey); - if ($day==$jour && $month==$mois && $year==$annee) + if ($day == $jour && $month == $mois && $year == $annee) { foreach ($eventarray[$daykey] as $index => $event) { - if ($i < $maxprint || $maxprint == 0 || ! empty($conf->global->MAIN_JS_SWITCH_AGENDA)) + if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) { - $keysofuserassigned=array_keys($event->userassigned); - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); + $keysofuserassigned = array_keys($event->userassigned); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); // Define $color (Hex string like '0088FF') and $cssclass of event - $color=-1; $cssclass=''; $colorindex=-1; + $color = -1; $cssclass = ''; $colorindex = -1; if (in_array($user->id, $keysofuserassigned)) { - $cssclass='family_mytasks'; + $cssclass = 'family_mytasks'; if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file { $numical++; - if (! empty($event->icalname)) { - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { + if (!empty($event->icalname)) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } $numicals[dol_string_nospecial($event->icalname)]++; } - $color=($event->icalcolor?$event->icalcolor:-1); - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); } elseif ($event->type_code == 'BIRTHDAY') { - $numbirthday++; $colorindex=2; $cssclass='family_birthday unmovable'; $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; - $color=($event->icalcolor?$event->icalcolor:-1); - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); if (empty($cacheusers[$event->userownerid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid]=$newuser; + $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; } if ($color < 0) // Color was not set on user card. Set color according to color index. { // Define color index if not yet defined - $idusertouse=($event->userownerid?$event->userownerid:0); + $idusertouse = ($event->userownerid ? $event->userownerid : 0); if (isset($colorindexused[$idusertouse])) { - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { - $colorindex=$nextindextouse; - $colorindexused[$idusertouse]=$colorindex; - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color } //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
'; // Define color - $color=sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } - $cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; + $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd; // Defined style to disable drag and drop feature - if ($event->type_code =='AC_OTH_AUTO') + if ($event->type_code == 'AC_OTH_AUTO') { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } elseif ($event->type_code == 'ICALEVENT') { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { - $cssclass.= " unmovable"; + $cssclass .= " unmovable"; } } - else{ + else { if ($user->rights->agenda->allactions->create || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - $cssclass.= " movable cursormove"; - }else{ - $cssclass.= " unmovable"; + $cssclass .= " movable cursormove"; + } else { + $cssclass .= " unmovable"; } } - $h=''; $nowrapontd=1; - if ($action == 'show_day') { $h='height: 100%; '; $nowrapontd=0; } - if ($action == 'show_week') { $h='height: 100%; '; $nowrapontd=0; } + $h = ''; $nowrapontd = 1; + if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } + if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } // Show rect of event print "\n"; @@ -1499,9 +1499,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa //print 'border: 1px solid #ccc" width="100%"'; print '">'; print '
'; - print ''; // Status - Percent - $withstatus=0; + $withstatus = 0; if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { - $withstatus=1; - if ($event->percentage >= 0) $withstatus=2; + $withstatus = 1; + if ($event->percentage >= 0) $withstatus = 2; } - print '
'; + print ''; - $daterange=''; + $daterange = ''; if ($event->type_code == 'BIRTHDAY') // It's a birthday { @@ -1528,11 +1528,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { - $daterange.=dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) - $daterange.='-'; + $daterange .= '-'; //else //print '...'; } @@ -1541,14 +1541,14 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa { if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { - $daterange.='...'; + $daterange .= '...'; } } // Hour end if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - $daterange.=dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user } } else @@ -1561,34 +1561,34 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Show title $titletoshow = $daterange; - $titletoshow.=($titletoshow?' ':'').($event->label?$event->label:$event->libelle); + $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle); if ($event->type_code == 'ICALEVENT') print $titletoshow; else { - $savlabel=$event->label?$event->label:$event->libelle; - $event->label=$titletoshow; - $event->libelle=$titletoshow; + $savlabel = $event->label ? $event->label : $event->libelle; + $event->label = $titletoshow; + $event->libelle = $titletoshow; print $event->getNomUrl(0, $maxnbofchar, 'cal_event', '', 0, 0); - $event->label=$savlabel; - $event->libelle=$savlabel; + $event->label = $savlabel; + $event->libelle = $savlabel; } // Loop on each assigned user - $listofusertoshow=''; - $posuserassigned=0; - foreach($event->userassigned as $tmpid => $tmpdata) + $listofusertoshow = ''; + $posuserassigned = 0; + foreach ($event->userassigned as $tmpid => $tmpdata) { - if (! $posuserassigned && $titletoshow) $listofusertoshow.='
'; + if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
'; $posuserassigned++; if (empty($cacheusers[$tmpid])) { - $newuser=new User($db); + $newuser = new User($db); $newuser->fetch($tmpid); - $cacheusers[$tmpid]=$newuser; + $cacheusers[$tmpid] = $newuser; } - $listofusertoshow.=$cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); } print $listofusertoshow; @@ -1598,35 +1598,35 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->cotact->id > 0) ? $event->contact->id : 0)); // If action related to company / contact - $linerelatedto=''; + $linerelatedto = ''; if ($thirdparty_id > 0) { - if (! isset($cachethirdparties[$thirdparty_id]) || ! is_object($cachethirdparties[$thirdparty_id])) + if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) { - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); $thirdparty->fetch($thirdparty_id); - $cachethirdparties[$thirdparty_id]=$thirdparty; + $cachethirdparties[$thirdparty_id] = $thirdparty; } - else $thirdparty=$cachethirdparties[$thirdparty_id]; - if (! empty($thirdparty->id)) $linerelatedto.=$thirdparty->getNomUrl(1, '', 0); + else $thirdparty = $cachethirdparties[$thirdparty_id]; + if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); } - if (! empty($contact_id) && $contact_id > 0) + if (!empty($contact_id) && $contact_id > 0) { - if (! is_object($cachecontacts[$contact_id])) + if (!is_object($cachecontacts[$contact_id])) { - $contact=new Contact($db); + $contact = new Contact($db); $contact->fetch($contact_id); - $cachecontacts[$contact_id]=$contact; + $cachecontacts[$contact_id] = $contact; } - else $contact=$cachecontacts[$contact_id]; - if ($linerelatedto) $linerelatedto.=' '; - if (! empty($contact->id)) $linerelatedto.=$contact->getNomUrl(1, '', 0); + else $contact = $cachecontacts[$contact_id]; + if ($linerelatedto) $linerelatedto .= ' '; + if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); } - if (! empty($event->fk_element) && $event->fk_element > 0 && ! empty($event->elementtype) && ! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) + if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ($linerelatedto) $linerelatedto.='
'; - $linerelatedto.=dolGetElementUrl($event->fk_element, $event->elementtype, 1); + if ($linerelatedto) $linerelatedto .= '
'; + $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); } if ($linerelatedto) print '
'.$linerelatedto; } @@ -1643,13 +1643,13 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print '
'; + print ''; if ($withstatus) print $event->getLibStatut(3, 1); else print ' '; print '
'; @@ -1674,9 +1674,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa break; } } - if (! $i) print ' '; + if (!$i) print ' '; - if (! empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) + if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { print '
'.img_picto("all", "1downarrow_selected.png").' +'.$langs->trans("More").'...
'; //print ' +'.(count($eventarray[$daykey])-$maxprint); @@ -1695,9 +1695,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print ''."\n"; } - print ''; // td tr + print ''; // td tr - print ''; // table + print ''; // table print "\n"; } @@ -1712,12 +1712,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa */ function dol_color_minus($color, $minus, $minusunit = 16) { - $newcolor=$color; + $newcolor = $color; if ($minusunit == 16) { - $newcolor[0]=dechex(max(min(hexdec($newcolor[0])-$minus, 15), 0)); - $newcolor[2]=dechex(max(min(hexdec($newcolor[2])-$minus, 15), 0)); - $newcolor[4]=dechex(max(min(hexdec($newcolor[4])-$minus, 15), 0)); + $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); + $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); + $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); } else { @@ -1745,7 +1745,7 @@ function sort_events_by_date($a, $b) } // Events have same start time and no end time - if ((! is_numeric($b->datef)) || (! is_numeric($a->datef))) + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) { return sort_events_by_percentage($a, $b); } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index d405d2526d3..6e26e732010 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.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.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.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.commande.class.php'; -if (! $user->rights->societe->lire) accessforbidden(); +if (!$user->rights->societe->lire) accessforbidden(); $hookmanager = new HookManager($db); @@ -46,19 +46,19 @@ $hookmanager->initHooks(array('commercialindex')); // Load translation files required by the page $langs->loadLangs(array("commercial", "propal")); -$action=GETPOST('action', 'alpha'); -$bid=GETPOST('bid', 'int'); +$action = GETPOST('action', 'alpha'); +$bid = GETPOST('bid', 'int'); // Securite acces client -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } -$max=3; -$now=dol_now(); +$max = 3; +$now = dol_now(); /* * Actions @@ -71,11 +71,11 @@ $now=dol_now(); $form = new Form($db); $formfile = new FormFile($db); -$companystatic=new Societe($db); -if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); -if (! empty($conf->supplier_proposal->enabled)) $supplierproposalstatic=new SupplierProposal($db); -if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); -if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); +$companystatic = new Societe($db); +if (!empty($conf->propal->enabled)) $propalstatic = new Propal($db); +if (!empty($conf->supplier_proposal->enabled)) $supplierproposalstatic = new SupplierProposal($db); +if (!empty($conf->commande->enabled)) $orderstatic = new Commande($db); +if (!empty($conf->fournisseur->enabled)) $supplierorderstatic = new CommandeFournisseur($db); llxHeader("", $langs->trans("CommercialArea")); @@ -83,37 +83,37 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search proposal - if (! empty($conf->propal->enabled) && $user->rights->propal->lire) + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $listofsearchfields['search_proposal']=array('text'=>'Proposal'); + $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); } // Search customer order - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder'); + $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); } // Search supplier proposal - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); + $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); } // Search supplier order - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { - $listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder'); + $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); } // Search intervention - if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { - $listofsearchfields['search_intervention']=array('text'=>'Intervention'); + $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); } // Search contract - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $listofsearchfields['search_contract']=array('text'=>'Contract'); + $listofsearchfields['search_contract'] = array('text'=>'Contract'); } if (count($listofsearchfields)) @@ -122,8 +122,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
'; print ''; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -143,22 +143,22 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /* * Draft proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propal->lire) +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + 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; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -172,27 +172,27 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; @@ -203,7 +203,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -227,22 +227,22 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) /* * Draft supplier proposals */ -if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $langs->load("supplier_proposal"); $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + 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; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -251,31 +251,31 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos print '
'; print '
'.$langs->trans("Search").'
'; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; - $propalstatic->ref_client=$obj->ref_client; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; print $propalstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; @@ -286,7 +286,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -309,20 +309,20 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos /* * Draft orders */ -if (! empty($conf->commande->enabled) && $user->rights->commande->lire) +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.fk_statut = 0"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.fk_statut = 0"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) @@ -333,34 +333,34 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'; print '
'.$langs->trans("SupplierProposalsDraft").($num?' '.$num.'':'').'
'.$langs->trans("SupplierProposalsDraft").($num ? ' '.$num.'' : '').'
'; - $supplierproposalstatic->id=$obj->rowid; - $supplierproposalstatic->ref=$obj->ref; + $supplierproposalstatic->id = $obj->rowid; + $supplierproposalstatic->ref = $obj->ref; $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; print $supplierproposalstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -373,7 +373,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -397,21 +397,21 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) /* * Draft suppliers orders */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql.= ", s.code_client"; - $sql.= ", s.code_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cf.fk_soc = s.rowid"; - $sql.= " AND cf.fk_statut = 0"; - $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND cf.fk_soc = ".$socid; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + $sql .= " AND cf.fk_statut = 0"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); if ($resql) @@ -422,34 +422,34 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
'; print '
'.$langs->trans("DraftOrders").($num?' '.$num.'':'').'
'.$langs->trans("DraftOrders").($num ? ' '.$num.'' : '').'
'; - $orderstatic->id=$obj->rowid; - $orderstatic->ref=$obj->ref; - $orderstatic->ref_client=$obj->ref_client; + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; print $orderstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'; print ''; - print ''; + print ''; if ($num > 0) { $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; print ''; - if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { print ''; } else { @@ -462,7 +462,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -484,24 +484,24 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
'; -$max=3; +$max = 3; /* * Last modified customers or prospects */ -if (! empty($conf->societe->enabled) && $user->rights->societe->lire) +if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql.= ", s.code_client"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.client IN (1, 2, 3)"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = $socid"; + $sql .= ", s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (1, 2, 3)"; + $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -516,7 +516,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) print '
'; print ''; print ''; @@ -526,12 +526,12 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) while ($i < $num) { $objp = $db->fetch_object($resql); - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; - $companystatic->client=$objp->client; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; + $companystatic->client = $objp->client; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print ''; print ''; print ''; print ''; print ''; @@ -630,26 +630,26 @@ if ($user->rights->agenda->myactions->read) /* * Last contracts */ -if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT { $langs->load("contracts"); $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql.= ", s.code_client"; - $sql.= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."product as p"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; - $sql.= " AND c.fk_product = p.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY c.tms DESC"; - $sql.= $db->plimit(5, 0); + $sql .= ", s.code_client"; + $sql .= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " AND c.fk_product = p.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY c.tms DESC"; + $sql .= $db->plimit(5, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -661,18 +661,18 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO print ''; $i = 0; - $staticcontrat=new Contrat($db); + $staticcontrat = new Contrat($db); while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print ''."\n"; print "\n"; @@ -692,23 +692,23 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO /* * Opened 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 as name, s.rowid, s.code_client"; - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_statut = 1"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; + $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -720,7 +720,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '
'.$langs->trans("DraftSuppliersOrders").($num?' '.$num.'':'').'
'.$langs->trans("DraftSuppliersOrders").($num ? ' '.$num.'' : '').'
'; - $supplierorderstatic->id=$obj->rowid; - $supplierorderstatic->ref=$obj->ref; - $supplierorderstatic->ref_supplier=$obj->ref_suppliert; + $supplierorderstatic->id = $obj->rowid; + $supplierorderstatic->ref = $obj->ref; + $supplierorderstatic->ref_supplier = $obj->ref_suppliert; $supplierorderstatic->total_ht = $obj->total_ht; $supplierorderstatic->total_tva = $obj->total_tva; $supplierorderstatic->total_ttc = $obj->total_ttc; print $supplierorderstatic->getNomUrl(1); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); else print $langs->trans("BoxTitleLastModifiedCustomers", $max); print ''.$langs->trans("FullList").'
'.$companystatic->getNomUrl(1, 'customer', 48).''; @@ -554,20 +554,20 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) } // Last suppliers -if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql.= ", s.code_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY s.datec DESC"; - $sql.= $db->plimit($max, 0); + $sql .= ", s.code_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.fournisseur = 1"; + $sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY s.datec DESC"; + $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) @@ -586,11 +586,11 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) while ($i < $num && $i < $max) { $objp = $db->fetch_object($result); - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print '
'.$companystatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($objp->dm), 'day').'
'.$langs->trans("LastContracts", 5).'
contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; $companystatic->code_client = $objp->code_client; $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas=$objp->canvas; + $companystatic->canvas = $objp->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print '".$staticcontrat->LibStatut($obj->statut, 3)."
'; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -730,9 +730,9 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) // Ref print ''; print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - $propalstatic->id=$obj->propalid; - $propalstatic->ref=$obj->ref; - $propalstatic->ref_client=$obj->ref_client; + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; @@ -745,26 +745,26 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; print "
'; - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -834,9 +834,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) // Ref print ''; print '
'.$langs->trans("OrdersOpened").' '.$num.'
'; - $orderstatic->id=$obj->commandeid; - $orderstatic->ref=$obj->ref; - $orderstatic->ref_client=$obj->ref_client; + $orderstatic->id = $obj->commandeid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; @@ -849,26 +849,26 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); print '
'; print "
'; - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'customer', 44); print ''; print dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ht).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - print ''; + print ''; print ''; - print ''; + print ''; - print ''; + print ''; // Errors to - print ''; // Status - print ''; + print ''; // Nb of distinct emails print ''; print ''; @@ -617,36 +617,36 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire) /** * Social contributions to pay */ -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if (!$socid) { - $chargestatic=new ChargeSociales($db); + $chargestatic = new ChargeSociales($db); $sql = "SELECT c.rowid, c.amount, c.date_ech, c.paye,"; - $sql.= " cc.libelle as label,"; - $sql.= " SUM(pc.amount) as sumpaid"; - $sql.= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid"; - $sql.= " WHERE c.fk_type = cc.id"; - $sql.= " AND c.entity IN (".getEntity('tax').')'; - $sql.= " AND c.paye = 0"; + $sql .= " cc.libelle as label,"; + $sql .= " SUM(pc.amount) as sumpaid"; + $sql .= " FROM (".MAIN_DB_PREFIX."c_chargesociales as cc, ".MAIN_DB_PREFIX."chargesociales as c)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = c.rowid"; + $sql .= " WHERE c.fk_type = cc.id"; + $sql .= " AND c.entity IN (".getEntity('tax').')'; + $sql .= " AND c.paye = 0"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSocialContributions', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSocialContributions', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; + $sql .= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
'; print '
' . $langs->trans("Ref") . '
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback); print '
' . $langs->trans("MailTitle") . '' . $object->titre . '
'.$langs->trans("MailTitle").''.$object->titre.'
' . $langs->trans("MailFrom") . '' . dol_print_email($object->email_from, 0, 0, 0, 0, 1) . '
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
' . $langs->trans("MailErrorsTo") . '' . dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); + print '
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : '0'); - if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { + if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { $text = $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); print $form->textwithpicto($nbemail, $text, 1, 'warning'); } else { @@ -458,7 +458,7 @@ if ($object->fetch($id) >= 0) { // Show email selectors if ($object->statut == 0 && $user->rights->mailing->creer) { - include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/advtarget.tpl.php'; } } diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f6e27fffaa3..f2754658f37 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -36,11 +36,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("mails"); // Security check -if (! $user->rights->mailing->lire || $user->socid > 0) accessforbidden(); +if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden(); // 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'); @@ -48,23 +48,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="email"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "email"; +if (!$sortorder) $sortorder = "ASC"; -$id=GETPOST('id', 'int'); -$rowid=GETPOST('rowid', 'int'); -$action=GETPOST('action', 'aZ09'); -$search_lastname=GETPOST("search_lastname", 'alphanohtml'); -$search_firstname=GETPOST("search_firstname", 'alphanohtml'); -$search_email=GETPOST("search_email", 'alphanohtml'); -$search_other=GETPOST("search_other", 'alphanohtml'); -$search_dest_status=GETPOST('search_dest_status', 'alphanohtml'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); +$action = GETPOST('action', 'aZ09'); +$search_lastname = GETPOST("search_lastname", 'alphanohtml'); +$search_firstname = GETPOST("search_firstname", 'alphanohtml'); +$search_email = GETPOST("search_email", 'alphanohtml'); +$search_other = GETPOST("search_other", 'alphanohtml'); +$search_dest_status = GETPOST('search_dest_status', 'alphanohtml'); // Search modules dirs $modulesdir = dolGetModulesDirs('/mailings'); $object = new Mailing($db); -$result=$object->fetch($id); +$result = $object->fetch($id); /* @@ -73,8 +73,8 @@ $result=$object->fetch($id); if ($action == 'add') { - $module=GETPOST("module", 'alpha'); - $result=-1; + $module = GETPOST("module", 'alpha'); + $result = -1; foreach ($modulesdir as $dir) { @@ -93,7 +93,7 @@ if ($action == 'add') // Add targets into database $obj = new $classname($db); dol_syslog("Call add_to_target on class ".$classname); - $result=$obj->add_to_target($id); + $result = $obj->add_to_target($id); } } if ($result > 0) @@ -109,7 +109,7 @@ if ($action == 'add') } if ($result < 0) { - setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors'); + setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors'); } } @@ -128,7 +128,7 @@ if (GETPOST('exportcsv', 'int')) { $completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv'; header('Content-Type: text/csv'); - header('Content-Disposition: attachment;filename=' . $completefilename); + header('Content-Disposition: attachment;filename='.$completefilename); // List of selected targets $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,"; @@ -137,7 +137,7 @@ if (GETPOST('exportcsv', 'int')) $sql .= " WHERE mc.fk_mailing=".$object->id; $sql .= $db->order($sortfield, $sortorder); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -145,17 +145,17 @@ if (GETPOST('exportcsv', 'int')) while ($obj = $db->fetch_object($resql)) { - print $obj->rowid . $sep; - print $obj->lastname . $sep; - print $obj->firstname . $sep; - print $obj->email . $sep; - print $obj->other . $sep; - print $obj->date_envoi . $sep; - print $obj->tms . $sep; - print $obj->source_url . $sep; - print $obj->source_id . $sep; - print $obj->source_type . $sep; - print $obj->error_text . $sep; + print $obj->rowid.$sep; + print $obj->lastname.$sep; + print $obj->firstname.$sep; + print $obj->email.$sep; + print $obj->other.$sep; + print $obj->date_envoi.$sep; + print $obj->tms.$sep; + print $obj->source_url.$sep; + print $obj->source_id.$sep; + print $obj->source_type.$sep; + print $obj->error_text.$sep; print "\n"; } @@ -171,11 +171,11 @@ if (GETPOST('exportcsv', 'int')) if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql="DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; - $resql=$db->query($sql); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; + $resql = $db->query($sql); if ($resql) { - if (! empty($id)) + if (!empty($id)) { $obj = new MailingTargets($db); $obj->update_nb($id); @@ -195,13 +195,13 @@ if ($action == 'delete') } // 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_lastname=''; - $search_firstname=''; - $search_email=''; - $search_other=''; - $search_dest_status=''; + $search_lastname = ''; + $search_firstname = ''; + $search_email = ''; + $search_other = ''; + $search_dest_status = ''; } @@ -223,16 +223,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlright=''; + $morehtmlright = ''; $nbtry = $nbok = 0; if ($object->statut == 2 || $object->statut == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); - $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; - if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); - $morehtmlright.=')   '; + $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright .= ')   '; } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -254,22 +254,22 @@ if ($object->fetch($id) >= 0) 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 && $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'); @@ -290,12 +290,12 @@ if ($object->fetch($id) >= 0) print '
'; - $allowaddtarget=($object->statut == 0); + $allowaddtarget = ($object->statut == 0); // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { - print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1):''), 'generic'); + print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic'); //print ''; print '
'; @@ -317,22 +317,22 @@ if ($object->fetch($id) >= 0) foreach ($modulesdir as $dir) { - $modulenames=array(); + $modulenames = array(); // Load modules attributes in arrays (name, numero, orders) from dir directory //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for modules"); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) { if ($reg[1] == 'example') continue; - $modulenames[]=$reg[1]; + $modulenames[] = $reg[1]; } } } @@ -345,7 +345,7 @@ if ($object->fetch($id) >= 0) $var = true; // Loop on each submodule - foreach($modulenames as $modulename) + foreach ($modulenames as $modulename) { // Loading Class $file = $dir.$modulename.".modules.php"; @@ -355,12 +355,12 @@ if ($object->fetch($id) >= 0) $obj = new $classname($db); // Check dependencies - $qualified=(isset($obj->enabled)?$obj->enabled:1); + $qualified = (isset($obj->enabled) ? $obj->enabled : 1); foreach ($obj->require_module as $key) { - if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin)) + if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) { - $qualified=0; + $qualified = 0; //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif"; break; } @@ -369,7 +369,7 @@ if ($object->fetch($id) >= 0) // Si le module mailing est qualifie if ($qualified) { - $var = ! $var; + $var = !$var; if ($allowaddtarget) { @@ -382,16 +382,16 @@ if ($object->fetch($id) >= 0) } print '
'; - if (empty($obj->picto)) $obj->picto='generic'; + if (empty($obj->picto)) $obj->picto = 'generic'; print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle pictomodule"'); print ' '; print $obj->getDesc(); print '
'; try { - $nbofrecipient=$obj->getNbOfRecipients(''); + $nbofrecipient = $obj->getNbOfRecipients(''); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -411,9 +411,9 @@ if ($object->fetch($id) >= 0) if ($allowaddtarget) { try { - $filter=$obj->formFilter(); + $filter = $obj->formFilter(); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -451,11 +451,11 @@ if ($object->fetch($id) >= 0) $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.fk_mailing=".$object->id; - if ($search_lastname) $sql.= natural_search("mc.lastname", $search_lastname); - if ($search_firstname) $sql.= natural_search("mc.firstname", $search_firstname); - if ($search_email) $sql.= natural_search("mc.email", $search_email); - if ($search_other) $sql.= natural_search("mc.other", $search_other); - if ($search_dest_status != '' && $search_dest_status >= -1) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; + if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname); + if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname); + if ($search_email) $sql .= natural_search("mc.email", $search_email); + if ($search_other) $sql .= natural_search("mc.other", $search_other); + if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -472,20 +472,20 @@ if ($object->fetch($id) >= 0) } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets - $sql .= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $param = "&id=".$object->id; //if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname); - if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname); - if ($search_email) $param.= "&search_email=".urlencode($search_email); - if ($search_other) $param.= "&search_other=".urlencode($search_other); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname); + if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname); + if ($search_email) $param .= "&search_email=".urlencode($search_email); + if ($search_other) $param .= "&search_other=".urlencode($search_other); print ''; print ''; @@ -494,11 +494,11 @@ if ($object->fetch($id) >= 0) print ''; print ''; - $morehtmlcenter=''; + $morehtmlcenter = ''; if ($allowaddtarget) { - $morehtmlcenter=''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition">'.$langs->trans("TargetsReset").''; + $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition">'.$langs->trans("TargetsReset").''; } - $morehtmlcenter.=' id.'">'.$langs->trans("Download").''; + $morehtmlcenter .= ' id.'">'.$langs->trans("Download").''; print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); @@ -555,12 +555,12 @@ if ($object->fetch($id) >= 0) print ''; // Action column print '
'; print ''; - if ($page) $param.= "&page=".urlencode($page); + if ($page) $param .= "&page=".urlencode($page); print ''; print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder); @@ -584,10 +584,10 @@ if ($object->fetch($id) >= 0) include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $objectstaticmember=new Adherent($db); - $objectstaticuser=new User($db); - $objectstaticcompany=new Societe($db); - $objectstaticcontact=new Contact($db); + $objectstaticmember = new Adherent($db); + $objectstaticuser = new User($db); + $objectstaticcompany = new Societe($db); + $objectstaticcontact = new Contact($db); while ($i < min($num, $limit)) { @@ -601,7 +601,7 @@ if ($object->fetch($id) >= 0) print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $total_ttc += $obj->total_ttc; + $total_ttc += $obj->total_ttc; $total += $obj->total_ht; - $totalam += $obj->am; + $totalam += $obj->am; $i++; } } else { - $colspan=5; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 5; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
'; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
'; if (empty($obj->source_id) || empty($obj->source_type)) { - print empty($obj->source_url)?'':$obj->source_url; // For backward compatibility + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility } else { diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 1a15ac2ca64..1dc7a430575 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -25,7 +25,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $hookmanager = new HookManager($db); @@ -38,14 +38,14 @@ $langs->loadLangs(array('commercial', 'orders')); // Security check -$result=restrictedArea($user, 'mailing'); +$result = restrictedArea($user, 'mailing'); /* * View */ -$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('', 'EMailing', $help_url); print load_fiche_titre($langs->trans("MailingArea")); @@ -77,18 +77,18 @@ print '
'; print ''; print ''; -$dir=DOL_DOCUMENT_ROOT."/core/modules/mailings"; -$handle=opendir($dir); +$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings"; +$handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) { - $modulename=$reg[1]; + $modulename = $reg[1]; if ($modulename == 'example') continue; // Loading Class @@ -97,12 +97,12 @@ if (is_resource($handle)) require_once $file; $mailmodule = new $classname($db); - $qualified=1; + $qualified = 1; foreach ($mailmodule->require_module as $key) { - if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin)) + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) { - $qualified=0; + $qualified = 0; //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; break; } @@ -115,13 +115,13 @@ if (is_resource($handle)) { print ''; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($result); 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/index.php b/htdocs/compta/index.php index 5199903b9ff..37400ab25a3 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -32,11 +32,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->tax->enabled)) +if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; // L'espace compta/treso doit toujours etre actif car c'est un espace partage @@ -48,21 +48,21 @@ if (! empty($conf->tax->enabled)) // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) $langs->load("orders"); -$action=GETPOST('action', 'alpha'); -$bid=GETPOST('bid', 'int'); +$action = GETPOST('action', 'alpha'); +$bid = GETPOST('bid', 'int'); // Security check -$socid=''; +$socid = ''; if ($user->socid > 0) { $action = ''; $socid = $user->socid; } -$max=3; +$max = 3; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('invoiceindex')); @@ -76,10 +76,10 @@ $hookmanager->initHooks(array('invoiceindex')); * View */ -$now=dol_now(); +$now = dol_now(); -$facturestatic=new Facture($db); -$facturesupplierstatic=new FactureFournisseur($db); +$facturestatic = new Facture($db); +$facturesupplierstatic = new FactureFournisseur($db); $form = new Form($db); $formfile = new FormFile($db); @@ -93,22 +93,22 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'invoicing' print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search customer invoices - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $listofsearchfields['search_invoice']=array('text'=>'CustomerInvoice'); + $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); } // Search supplier invoices - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { - $listofsearchfields['search_supplier_invoice']=array('text'=>'SupplierInvoice'); + $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); } - if (! empty($conf->don->enabled) && $user->rights->don->lire) + if (!empty($conf->don->enabled) && $user->rights->don->lire) { $langs->load("donations"); - $listofsearchfields['search_donation']=array('text'=>'Donation'); + $listofsearchfields['search_donation'] = array('text'=>'Donation'); } if (count($listofsearchfields)) @@ -117,8 +117,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
'; print '
'.$langs->trans("TargetsStatistics").'
'.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; @@ -154,12 +154,12 @@ print '
'; /* * List of last emailings */ -$limit=10; +$limit = 10; $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat"; -$sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; -$sql.= " ORDER BY m.date_creat DESC"; -$sql.= " LIMIT ".$limit; -$result=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; +$sql .= " ORDER BY m.date_creat DESC"; +$sql .= " LIMIT ".$limit; +$result = $db->query($sql); if ($result) { print '
'; print ''; @@ -174,10 +174,10 @@ if ($result) { { $i = 0; - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($result); - $mailstatic=new Mailing($db); + $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; @@ -185,7 +185,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; $i++; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 82bf49261a1..32fe301489e 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -60,13 +60,13 @@ if ($_POST["action"] == 'setpricelevel') llxHeader(); -$userstatic=new User($db); +$userstatic = new User($db); if ($_socid > 0) { // On recupere les donnees societes par l'objet $objsoc = new Societe($db); - $objsoc->id=$_socid; + $objsoc->id = $_socid; $objsoc->fetch($_socid, $to); if ($errmesg) @@ -81,9 +81,9 @@ if ($_socid > 0) $head = societe_prepare_head($objsoc); - $tabchoice=''; - if ($objsoc->client == 1) $tabchoice='customer'; - if ($objsoc->client == 2) $tabchoice='prospect'; + $tabchoice = ''; + if ($objsoc->client == 1) $tabchoice = 'customer'; + if ($objsoc->client == 2) $tabchoice = 'prospect'; print ''; print ''; @@ -99,14 +99,14 @@ if ($_socid > 0) print ''; print "\n"; print ""; } @@ -235,20 +235,20 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) * */ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = 1"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY s.tms ASC"; -$sql.= $db->plimit(15, 0); +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.fk_stcomm = 1"; +$sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY s.tms ASC"; +$sql .= $db->plimit(15, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0 ) + if ($num > 0) { print '
'.$mailstatic->getNomUrl(1).''.dol_trunc($obj->titre, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail?$obj->nbemail:"0").''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
'; print $langs->trans("NewValue").''; print ''; @@ -129,11 +129,11 @@ if ($_socid > 0) */ $sql = "SELECT rc.rowid,rc.price_level, rc.datec as dc, u.rowid as uid, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_prices as rc, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE rc.fk_soc =". $objsoc->id; + $sql .= " WHERE rc.fk_soc =".$objsoc->id; $sql .= " AND u.rowid = rc.fk_user_author"; $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print ''; @@ -143,18 +143,18 @@ if ($_socid > 0) print ''; print ''; print ''; - $i = 0 ; + $i = 0; $num = $db->num_rows($resql); - while ($i < $num ) + while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print ''; print ''; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->login; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->login; print ''; print ''; $i++; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 459b6637230..bfd7bdb7baf 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -26,7 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $hookmanager = new HookManager($db); @@ -37,8 +37,8 @@ $hookmanager->initHooks(array('proposalindex')); $langs->loadLangs(array('propal', 'companies')); // Security check -$socid=GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) +$socid = GETPOST('socid', 'int'); +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; @@ -49,12 +49,12 @@ $result = restrictedArea($user, 'propal'); /* * View */ -$now=dol_now(); -$propalstatic=new Propal($db); -$companystatic=new Societe($db); +$now = dol_now(); +$propalstatic = new Propal($db); +$companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); -$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; +$help_url = "EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; llxHeader("", $langs->trans("ProspectionArea"), $help_url); @@ -65,7 +65,7 @@ print load_fiche_titre($langs->trans("ProspectionArea"), '', 'commercial'); print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { print ''; print '
'; @@ -83,25 +83,25 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele */ $sql = "SELECT count(p.rowid), p.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."propal as p"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE p.fk_soc = s.rowid"; -$sql.= " AND p.entity IN (".getEntity('propal').")"; -if ($user->socid) $sql.=' AND p.fk_soc = '.$user->socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " AND p.fk_statut IN (0,1,2,3,4)"; -$sql.= " GROUP BY p.fk_statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."propal as p"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE p.fk_soc = s.rowid"; +$sql .= " AND p.entity IN (".getEntity('propal').")"; +if ($user->socid) $sql .= ' AND p.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " AND p.fk_statut IN (0,1,2,3,4)"; +$sql .= " GROUP BY p.fk_statut"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - $total=0; - $totalinprocess=0; - $dataseries=array(); - $vals=array(); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $vals = array(); // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) while ($i < $num) { @@ -110,10 +110,10 @@ if ($resql) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { - $vals[$row[1]]=$row[0]; - $totalinprocess+=$row[0]; + $vals[$row[1]] = $row[0]; + $totalinprocess += $row[0]; } - $total+=$row[0]; + $total += $row[0]; } $i++; } @@ -122,15 +122,15 @@ if ($resql) print '
'; print '
'.$langs->trans("PriceLevel").''.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc), "dayhour").''.$obj->price_level.' '.$userstatic->getNomUrl(1).'
'; print ''."\n"; - $listofstatus=array(0,1,2,3,4); + $listofstatus = array(0, 1, 2, 3, 4); foreach ($listofstatus as $status) { - $dataseries[]=array($propalstatic->LibStatut($status, 1), (isset($vals[$status])?(int) $vals[$status]:0)); - if (! $conf->use_javascript_ajax) + $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if (!$conf->use_javascript_ajax) { print ''; print ''; - print ''; + print ''; print "\n"; } } @@ -146,7 +146,7 @@ if ($resql) $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100%'); $dolgraph->draw('idgraphthirdparties'); - print $dolgraph->show($total?0:1); + print $dolgraph->show($total ? 0 : 1); print ''; } @@ -164,19 +164,19 @@ else /* * Draft proposals */ -if (! empty($conf->propal->enabled)) +if (!empty($conf->propal->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('propal').")"; - $sql.= " AND c.fk_statut = 0"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('propal').")"; + $sql .= " AND c.fk_statut = 0"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -189,20 +189,20 @@ if (! empty($conf->propal->enabled)) print ''; $i = 0; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($resql); print ''; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''; print ''; @@ -212,7 +212,7 @@ if (! empty($conf->propal->enabled)) { print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } @@ -227,26 +227,26 @@ if (! empty($conf->propal->enabled)) print '
'; -$max=5; +$max = 5; /* * Last modified proposals */ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; -$sql.= " date_cloture as datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('propal').")"; +$sql .= " date_cloture as datec"; +$sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; +$sql .= ", ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('propal').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.tms DESC"; -$sql.= $db->plimit($max, 0); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY c.tms DESC"; +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
'; @@ -265,8 +265,8 @@ if ($resql) print '
'; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''; print ''; @@ -307,25 +307,25 @@ else dol_print_error($db); /* * Opened proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $langs->load("propal"); - $now=dol_now(); + $now = dol_now(); $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql.= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND p.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; + $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; - $result=$db->query($sql); + $result = $db->query($sql); if ($result) { $total = 0; @@ -337,7 +337,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print '
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status])?$vals[$status]:0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$langs->trans("DraftPropals").' '.$num.'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 24).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total").''.price($total)."
'; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->rowid; + $propalstatic->ref = $obj->ref; print ''; print ''; print '
'; @@ -278,18 +278,18 @@ if ($resql) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; print '
'.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').'
'; print ''; - $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) { $obj = $db->fetch_object($result); @@ -347,8 +347,8 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) // Ref print '"; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print ''."\n"; print '"; } - elseif ($total>0) + elseif ($total > 0) { print '"; } diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index b2cc1d8bbda..4bdcbae59a8 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -41,7 +41,7 @@ if ($user->socid > 0) * View */ -$companystatic=new Societe($db); +$companystatic = new Societe($db); llxHeader(); @@ -52,9 +52,9 @@ print load_fiche_titre($langs->trans("ProspectionArea")); print '
'; -if (! empty($conf->propal->enabled)) +if (!empty($conf->propal->enabled)) { - $var=false; + $var = false; print ''; print ''; print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - $propalstatic->id=$obj->propalid; - $propalstatic->ref=$obj->ref; + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; print ''; print ''; print '
'; @@ -358,18 +358,18 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; print "
'.$companystatic->getNomUrl(1, 'customer', 44).''; @@ -384,7 +384,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { print '
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 
'; @@ -72,22 +72,22 @@ if (! empty($conf->propal->enabled)) */ $sql = "SELECT count(*) as cc, st.libelle, st.id"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st "; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.client IN (2, 3)"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " GROUP BY st.id"; -$sql.= " ORDER BY st.id"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.fk_stcomm = st.id"; +$sql .= " AND s.client IN (2, 3)"; +$sql .= " AND s.entity IN (".getEntity($companystatic->element).")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " GROUP BY st.id"; +$sql .= " ORDER BY st.id"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0 ) + if ($num > 0) { print '
'; print ''; @@ -111,21 +111,21 @@ if ($resql) /* * Liste des propal brouillons */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_statut = 0"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $total=0; + $total = 0; $num = $db->num_rows($resql); $i = 0; if ($num > 0) @@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total>0) { + if ($total > 0) { print '"; } print "
'.$langs->trans("Total")."".price($total)."

"; @@ -163,29 +163,29 @@ print '
'; /* * Actions commerciales a faire */ -if (! empty($conf->agenda->enabled)) show_array_actions_to_do(10); +if (!empty($conf->agenda->enabled)) show_array_actions_to_do(10); /* * Dernieres propales ouvertes */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; - $sql.= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_propalst as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.fk_statut = c.id"; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= " ORDER BY p.rowid DESC"; - $sql.= $db->plimit(5, 0); + $sql .= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.fk_statut = c.id"; + $sql .= " AND p.fk_statut = 1"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.rowid DESC"; + $sql .= $db->plimit(5, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $total = 0; @@ -205,10 +205,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'
"; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, '', 44); print ""; @@ -217,7 +217,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $i++; $total += $obj->price; } - if ($total>0) + if ($total > 0) { print '
'.$langs->trans("Total")."".price($total)."
'; print ''; @@ -258,10 +258,10 @@ if ($resql) $obj = $db->fetch_object($resql); print ''; $i++; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 229fca58d18..a4f3fb0503b 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'orders', 'bills')); -$id=GETPOST("id", 'int'); +$id = GETPOST("id", 'int'); -$socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); +$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { @@ -45,7 +45,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); * Actions */ -if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) +if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -58,15 +58,15 @@ if (GETPOST('action', 'aZ09') == 'setremise') $discount_type = GETPOST('discount_type', 'int'); - if(! empty($discount_type)) { - $result=$object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user); + if (!empty($discount_type)) { + $result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user); } else { - $result=$object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user); + $result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user); } if ($result > 0) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -88,7 +88,7 @@ if (GETPOST('action', 'aZ09') == 'setremise') * View */ -$form=new Form($db); +$form = new Form($db); llxHeader(); @@ -116,13 +116,13 @@ if ($socid > 0) dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), -1, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; print '
'; - if (! $isCustomer && ! $isSupplier) { + if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; dol_fiche_end(); @@ -176,7 +176,7 @@ if ($socid > 0) print ' '; } if ($isSupplier) { - print ' '; + print ' '; } print ''; } @@ -197,7 +197,7 @@ if ($socid > 0) print '
'; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -208,8 +208,8 @@ if ($socid > 0) print '
'; - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
'; print '
'; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); @@ -218,15 +218,15 @@ if ($socid > 0) /* * List log of all customer percent discounts */ - $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; + $sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,"; + $sql .= " u.login, u.rowid as user_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user_author"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
'.$langs->trans("ProspectToContact").'
'; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; print $companystatic->getNomUrl(1, 'prospect', 44); print '
'; @@ -266,8 +266,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
'; print '
'; @@ -277,15 +277,15 @@ if ($socid > 0) /* * List log of all supplier percent discounts */ - $sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,"; - $sql.= " u.login, u.rowid as user_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user_author"; - $sql.= " ORDER BY rc.datec DESC"; + $sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,"; + $sql .= " u.login, u.rowid as user_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user_author"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
'; @@ -324,7 +324,7 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index b3d3140db09..ac79c1fe0a7 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -33,13 +33,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; // Load translation files required by the page $langs->loadLangs(array('orders', 'bills', 'companies')); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$action=GETPOST('action', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); // Security check -$socid = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); +$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); if ($user->socid > 0) { $socid = $user->socid; @@ -50,7 +50,7 @@ if ($user->socid > 0) * Actions */ -if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) +if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -61,82 +61,82 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ttc_1=GETPOST('amount_ttc_1'); - $amount_ttc_2=GETPOST('amount_ttc_2'); + $amount_ttc_1 = GETPOST('amount_ttc_1'); + $amount_ttc_2 = GETPOST('amount_ttc_2'); - $error=0; - $remid=GETPOST("remid")?GETPOST("remid"):0; - $discount=new DiscountAbsolute($db); - $res=$discount->fetch($remid); - if (! $res > 0) + $error = 0; + $remid = GETPOST("remid") ?GETPOST("remid") : 0; + $discount = new DiscountAbsolute($db); + $res = $discount->fetch($remid); + if (!$res > 0) { $error++; setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } - if (! $error && price2num($amount_ttc_1+$amount_ttc_2) != $discount->amount_ttc) + if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc) { $error++; setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } - if (! $error && $discount->fk_facture_line) + if (!$error && $discount->fk_facture_line) { $error++; setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors'); } - if (! $error) + if (!$error) { - $newdiscount1=new DiscountAbsolute($db); - $newdiscount2=new DiscountAbsolute($db); - $newdiscount1->fk_facture_source=$discount->fk_facture_source; - $newdiscount2->fk_facture_source=$discount->fk_facture_source; - $newdiscount1->fk_facture=$discount->fk_facture; - $newdiscount2->fk_facture=$discount->fk_facture; - $newdiscount1->fk_facture_line=$discount->fk_facture_line; - $newdiscount2->fk_facture_line=$discount->fk_facture_line; - $newdiscount1->fk_invoice_supplier_source=$discount->fk_invoice_supplier_source; - $newdiscount2->fk_invoice_supplier_source=$discount->fk_invoice_supplier_source; - $newdiscount1->fk_invoice_supplier=$discount->fk_invoice_supplier; - $newdiscount2->fk_invoice_supplier=$discount->fk_invoice_supplier; - $newdiscount1->fk_invoice_supplier_line=$discount->fk_invoice_supplier_line; - $newdiscount2->fk_invoice_supplier_line=$discount->fk_invoice_supplier_line; + $newdiscount1 = new DiscountAbsolute($db); + $newdiscount2 = new DiscountAbsolute($db); + $newdiscount1->fk_facture_source = $discount->fk_facture_source; + $newdiscount2->fk_facture_source = $discount->fk_facture_source; + $newdiscount1->fk_facture = $discount->fk_facture; + $newdiscount2->fk_facture = $discount->fk_facture; + $newdiscount1->fk_facture_line = $discount->fk_facture_line; + $newdiscount2->fk_facture_line = $discount->fk_facture_line; + $newdiscount1->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source; + $newdiscount2->fk_invoice_supplier_source = $discount->fk_invoice_supplier_source; + $newdiscount1->fk_invoice_supplier = $discount->fk_invoice_supplier; + $newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier; + $newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line; + $newdiscount2->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line; if ($discount->description == '(CREDIT_NOTE)' || $discount->description == '(DEPOSIT)') { - $newdiscount1->description=$discount->description; - $newdiscount2->description=$discount->description; + $newdiscount1->description = $discount->description; + $newdiscount2->description = $discount->description; } else { - $newdiscount1->description=$discount->description.' (1)'; - $newdiscount2->description=$discount->description.' (2)'; + $newdiscount1->description = $discount->description.' (1)'; + $newdiscount2->description = $discount->description.' (2)'; } - $newdiscount1->fk_user=$discount->fk_user; - $newdiscount2->fk_user=$discount->fk_user; - $newdiscount1->fk_soc=$discount->fk_soc; - $newdiscount2->fk_soc=$discount->fk_soc; - $newdiscount1->discount_type=$discount->discount_type; - $newdiscount2->discount_type=$discount->discount_type; - $newdiscount1->datec=$discount->datec; - $newdiscount2->datec=$discount->datec; - $newdiscount1->tva_tx=$discount->tva_tx; - $newdiscount2->tva_tx=$discount->tva_tx; - $newdiscount1->amount_ttc=$_POST["amount_ttc_1"]; - $newdiscount2->amount_ttc=price2num($discount->amount_ttc-$newdiscount1->amount_ttc); - $newdiscount1->amount_ht=price2num($newdiscount1->amount_ttc/(1+$newdiscount1->tva_tx/100), 'MT'); - $newdiscount2->amount_ht=price2num($newdiscount2->amount_ttc/(1+$newdiscount2->tva_tx/100), 'MT'); - $newdiscount1->amount_tva=price2num($newdiscount1->amount_ttc-$newdiscount1->amount_ht); - $newdiscount2->amount_tva=price2num($newdiscount2->amount_ttc-$newdiscount2->amount_ht); + $newdiscount1->fk_user = $discount->fk_user; + $newdiscount2->fk_user = $discount->fk_user; + $newdiscount1->fk_soc = $discount->fk_soc; + $newdiscount2->fk_soc = $discount->fk_soc; + $newdiscount1->discount_type = $discount->discount_type; + $newdiscount2->discount_type = $discount->discount_type; + $newdiscount1->datec = $discount->datec; + $newdiscount2->datec = $discount->datec; + $newdiscount1->tva_tx = $discount->tva_tx; + $newdiscount2->tva_tx = $discount->tva_tx; + $newdiscount1->amount_ttc = $_POST["amount_ttc_1"]; + $newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc); + $newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); + $newdiscount2->amount_ht = price2num($newdiscount2->amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); + $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); + $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); $db->begin(); - $discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source + $discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source - $discount->fk_invoice_supplier_source=0; - $res=$discount->delete($user); - $newid1=$newdiscount1->create($user); - $newid2=$newdiscount2->create($user); + $discount->fk_invoice_supplier_source = 0; + $res = $discount->delete($user); + $newid1 = $newdiscount1->create($user); + $newid2 = $newdiscount2->create($user); if ($res > 0 && $newid1 > 0 && $newid2 > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back exit; } else @@ -151,29 +151,29 @@ if ($action == 'setremise' && $user->rights->societe->creer) //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ht=GETPOST('amount_ht'); - $desc=GETPOST('desc', 'alpha'); - $tva_tx=GETPOST('tva_tx', 'alpha'); - $discount_type=! empty($_POST['discount_type'])?GETPOST('discount_type', 'alpha'):0; + $amount_ht = GETPOST('amount_ht'); + $desc = GETPOST('desc', 'alpha'); + $tva_tx = GETPOST('tva_tx', 'alpha'); + $discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0; if (price2num($amount_ht) > 0) { - $error=0; + $error = 0; if (empty($desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReasonDiscount")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $soc = new Societe($db); $soc->fetch($id); - $discountid=$soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type); + $discountid = $soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type); if ($discountid > 0) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage.'&discountid='.$discountid); exit; @@ -197,7 +197,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) } } -if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') +if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes') { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -205,12 +205,12 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') $db->begin(); $discount = new DiscountAbsolute($db); - $result=$discount->fetch(GETPOST("remid")); - $result=$discount->delete($user); + $result = $discount->fetch(GETPOST("remid")); + $result = $discount->delete($user); if ($result > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back exit; } else @@ -225,9 +225,9 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes') * View */ -$form=new Form($db); -$facturestatic=new Facture($db); -$facturefournstatic=new FactureFournisseur($db); +$form = new Form($db); +$facturestatic = new Facture($db); +$facturefournstatic = new FactureFournisseur($db); llxHeader('', $langs->trans("GlobalDiscount")); @@ -252,13 +252,13 @@ if ($socid > 0) dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object, 'socid', '', ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; print '
'; - if(! $isCustomer && ! $isSupplier) { + if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; dol_fiche_end(); @@ -273,21 +273,21 @@ if ($socid > 0) print '
'; - if($isCustomer) { // Calcul avoirs client en cours - $remise_all=$remise_user=0; + if ($isCustomer) { // Calcul avoirs client en cours + $remise_all = $remise_user = 0; $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND discount_type = 0"; // Exclude supplier discounts - $sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; - $sql.= " GROUP BY rc.fk_user"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND discount_type = 0"; // Exclude supplier discounts + $sql .= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; + $sql .= " GROUP BY rc.fk_user"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $remise_all+=$obj->amount; - if ($obj->fk_user == $user->id) $remise_user+=$obj->amount; + $remise_all += $obj->amount; + if ($obj->fk_user == $user->id) $remise_user += $obj->amount; } else { @@ -297,29 +297,29 @@ if ($socid > 0) print ''; print ''; - if (! empty($user->fk_soc)) // No need to show this for external users + if (!empty($user->fk_soc)) // No need to show this for external users { print ''; print ''; } } - if($isSupplier) { + if ($isSupplier) { // Calcul avoirs fournisseur en cours - $remise_all=$remise_user=0; + $remise_all = $remise_user = 0; $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND discount_type = 1"; // Exclude customer discounts - $sql.= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)"; - $sql.= " GROUP BY rc.fk_user"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND discount_type = 1"; // Exclude customer discounts + $sql .= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)"; + $sql .= " GROUP BY rc.fk_user"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $remise_all+=$obj->amount; - if ($obj->fk_user == $user->id) $remise_user+=$obj->amount; + $remise_all += $obj->amount; + if ($obj->fk_user == $user->id) $remise_user += $obj->amount; } else { @@ -329,7 +329,7 @@ if ($socid > 0) print ''; print ''; - if (! empty($user->fk_soc)) // No need to show this for external users + if (!empty($user->fk_soc)) // No need to show this for external users { print ''; print ''; @@ -348,16 +348,16 @@ if ($socid > 0) print '
'; - if($isCustomer && ! $isSupplier) { + if ($isCustomer && !$isSupplier) { print ''; } - if(! $isCustomer && $isSupplier) { + if (!$isCustomer && $isSupplier) { print ''; } print '
'.$langs->trans("CustomerAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("CustomerAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("SupplierAbsoluteDiscountAllUsers").''.$remise_all.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$langs->trans("SupplierAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'; - if($isCustomer && $isSupplier) { + if ($isCustomer && $isSupplier) { 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 '
'.$langs->trans('DiscountType').' '; print '   '; @@ -382,7 +382,7 @@ if ($socid > 0) { print '
'; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -407,44 +407,44 @@ if ($socid > 0) print load_fiche_titre($langs->trans("DiscountStillRemaining")); - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
'; print '
'; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); } $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description,"; - $sql.= " rc.fk_facture_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " fa.ref as ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user"; - $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; - $sql.= " ORDER BY rc.datec DESC"; + $sql .= " rc.datec as dc, rc.description,"; + $sql .= " rc.fk_facture_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " fa.ref as ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user"; + $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql .= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
'; print ''; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -452,7 +452,7 @@ if ($socid > 0) print ''; print ''; - $showconfirminfo=array(); + $showconfirminfo = array(); $i = 0; $num = $db->num_rows($resql); @@ -467,27 +467,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; } @@ -499,13 +499,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -515,18 +515,18 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else print ''; print ''; - if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) { - $showconfirminfo['rowid']=$obj->rowid; - $showconfirminfo['amount_ttc']=$obj->amount_ttc; + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; } $i++; } @@ -541,15 +541,15 @@ if ($socid > 0) if (count($showconfirminfo)) { - $amount1=price2num($showconfirminfo['amount_ttc']/2, 'MT'); - $amount2=($showconfirminfo['amount_ttc']-$amount1); - $formquestion=array( + $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); + $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -558,8 +558,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
'; print '
'; @@ -570,36 +570,36 @@ if ($socid > 0) * Liste remises fixes fournisseur restant en cours (= liees a aucune facture ni ligne de facture) */ $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description,"; - $sql.= " rc.fk_invoice_supplier_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " fa.ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc = " . $object->id; - $sql.= " AND rc.entity = " . $conf->entity; - $sql.= " AND u.rowid = rc.fk_user"; - $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql.= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; - $sql.= " ORDER BY rc.datec DESC"; + $sql .= " rc.datec as dc, rc.description,"; + $sql .= " rc.fk_invoice_supplier_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " fa.ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc = ".$object->id; + $sql .= " AND rc.entity = ".$conf->entity; + $sql .= " AND u.rowid = rc.fk_user"; + $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; + $sql .= " ORDER BY rc.datec DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
'; print '
'.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
'; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $obj->description).' '.$facturestatic->getNomURl(1); print ''.$langs->trans("NotConsumed").''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).''; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; //print '   '; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
'; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -607,7 +607,7 @@ if ($socid > 0) print ''; print ''; - $showconfirminfo=array(); + $showconfirminfo = array(); $i = 0; $num = $db->num_rows($resql); @@ -622,27 +622,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; } @@ -654,13 +654,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -670,18 +670,18 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else print ''; print ''; - if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) { - $showconfirminfo['rowid']=$obj->rowid; - $showconfirminfo['amount_ttc']=$obj->amount_ttc; + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; } $i++; } @@ -696,15 +696,15 @@ if ($socid > 0) if (count($showconfirminfo)) { - $amount1=price2num($showconfirminfo['amount_ttc']/2, 'MT'); - $amount2=($showconfirminfo['amount_ttc']-$amount1); - $formquestion=array( + $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); + $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); + $formquestion = array( 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -727,8 +727,8 @@ if ($socid > 0) print load_fiche_titre($langs->trans("DiscountAlreadyCounted")); - if($isCustomer) { - if($isSupplier) { + if ($isCustomer) { + if ($isSupplier) { print '
'; print '
'; print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); @@ -736,59 +736,59 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; - $sql.= " rc.fk_facture_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref,"; - $sql.= " fa.ref as ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " , ".MAIN_DB_PREFIX."facturedet as fc"; - $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc =". $object->id; - $sql.= " AND rc.fk_facture_line = fc.rowid"; - $sql.= " AND fc.fk_facture = f.rowid"; - $sql.= " AND rc.fk_user = u.rowid"; - $sql.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql.= " ORDER BY dc DESC"; + $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; + $sql .= " rc.fk_facture_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " f.rowid, f.ref,"; + $sql .= " fa.ref as ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."facturedet as fc"; + $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc =".$object->id; + $sql .= " AND rc.fk_facture_line = fc.rowid"; + $sql .= " AND fc.fk_facture = f.rowid"; + $sql .= " AND rc.fk_user = u.rowid"; + $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Remises liees a factures $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; - $sql2.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; - $sql2.= " rc.fk_facture_source,"; - $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref,"; - $sql2.= " fa.ref as ref, fa.type as type"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql2.= " , ".MAIN_DB_PREFIX."user as u"; - $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql2.= " WHERE rc.fk_soc =". $object->id; - $sql2.= " AND rc.fk_facture = f.rowid"; - $sql2.= " AND rc.fk_user = u.rowid"; - $sql2.= " AND rc.discount_type = 0"; // Eliminate supplier discounts - $sql2.= " ORDER BY dc DESC"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; + $sql2 .= " rc.fk_facture_source,"; + $sql2 .= " u.login, u.rowid as user_id,"; + $sql2 .= " f.rowid, f.ref,"; + $sql2 .= " fa.ref as ref, fa.type as type"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; + $sql2 .= " WHERE rc.fk_soc =".$object->id; + $sql2 .= " AND rc.fk_facture = f.rowid"; + $sql2 .= " AND rc.fk_user = u.rowid"; + $sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts + $sql2 .= " ORDER BY dc DESC"; - $resql=$db->query($sql); - $resql2=null; - if ($resql) $resql2=$db->query($sql2); + $resql = $db->query($sql); + $resql2 = null; + if ($resql) $resql2 = $db->query($sql2); if ($resql2) { print '
'; print '
'.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
'; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''.$langs->trans("NotConsumed").''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).''; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; //print '   '; - print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
'; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -796,26 +796,26 @@ if ($socid > 0) print ''; print ''; - $tab_sqlobj=array(); - $tab_sqlobjOrder=array(); + $tab_sqlobj = array(); + $tab_sqlobjOrder = array(); $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0;$i < $num; $i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } } $db->free($resql); $num = $db->num_rows($resql2); - for ($i = 0;$i < $num;$i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql2); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); @@ -823,8 +823,8 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0 ; - while ($i < $num ) + $i = 0; + while ($i < $num) { $obj = array_shift($tab_sqlobj); print ''; @@ -832,27 +832,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) { print ''; } @@ -864,13 +864,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -896,8 +896,8 @@ if ($socid > 0) } } - if($isSupplier) { - if($isCustomer) { + if ($isSupplier) { + if ($isCustomer) { print ''; // class="fichehalfleft" print '
'; print '
'; @@ -906,59 +906,59 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; - $sql.= " rc.fk_invoice_supplier_source,"; - $sql.= " u.login, u.rowid as user_id,"; - $sql.= " f.rowid, f.ref as ref,"; - $sql.= " fa.ref, fa.type as type"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; - $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql.= " WHERE rc.fk_soc =". $object->id; - $sql.= " AND rc.fk_invoice_supplier_line = fc.rowid"; - $sql.= " AND fc.fk_facture_fourn = f.rowid"; - $sql.= " AND rc.fk_user = u.rowid"; - $sql.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql.= " ORDER BY dc DESC"; + $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql .= " rc.fk_invoice_supplier_source,"; + $sql .= " u.login, u.rowid as user_id,"; + $sql .= " f.rowid, f.ref as ref,"; + $sql .= " fa.ref, fa.type as type"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; + $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql .= " WHERE rc.fk_soc =".$object->id; + $sql .= " AND rc.fk_invoice_supplier_line = fc.rowid"; + $sql .= " AND fc.fk_facture_fourn = f.rowid"; + $sql .= " AND rc.fk_user = u.rowid"; + $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Remises liees a factures $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; - $sql2.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; - $sql2.= " rc.fk_invoice_supplier_source,"; - $sql2.= " u.login, u.rowid as user_id,"; - $sql2.= " f.rowid, f.ref as ref,"; - $sql2.= " fa.ref, fa.type as type"; - $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql2.= " , ".MAIN_DB_PREFIX."user as u"; - $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql2.= " WHERE rc.fk_soc =". $object->id; - $sql2.= " AND rc.fk_invoice_supplier = f.rowid"; - $sql2.= " AND rc.fk_user = u.rowid"; - $sql2.= " AND rc.discount_type = 1"; // Eliminate customer discounts - $sql2.= " ORDER BY dc DESC"; + $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; + $sql2 .= " rc.fk_invoice_supplier_source,"; + $sql2 .= " u.login, u.rowid as user_id,"; + $sql2 .= " f.rowid, f.ref as ref,"; + $sql2 .= " fa.ref, fa.type as type"; + $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; + $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; + $sql2 .= " WHERE rc.fk_soc =".$object->id; + $sql2 .= " AND rc.fk_invoice_supplier = f.rowid"; + $sql2 .= " AND rc.fk_user = u.rowid"; + $sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts + $sql2 .= " ORDER BY dc DESC"; - $resql=$db->query($sql); - $resql2=null; - if ($resql) $resql2=$db->query($sql2); + $resql = $db->query($sql); + $resql2 = null; + if ($resql) $resql2 = $db->query($sql2); if ($resql2) { print '
'; print '
'.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
'; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; - $facturestatic->id=$obj->fk_facture_source; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).'
'; print ''; - print ''; // Need 120+ for format with AM/PM + print ''; // Need 120+ for format with AM/PM print ''; print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -966,26 +966,26 @@ if ($socid > 0) print ''; print ''; - $tab_sqlobj=array(); - $tab_sqlobjOrder=array(); + $tab_sqlobj = array(); + $tab_sqlobjOrder = array(); $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0;$i < $num; $i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } } $db->free($resql); $num = $db->num_rows($resql2); - for ($i = 0;$i < $num;$i++) + for ($i = 0; $i < $num; $i++) { $sqlobj = $db->fetch_object($resql2); $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dc); + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); } $db->free($resql2); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); @@ -993,8 +993,8 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0 ; - while ($i < $num ) + $i = 0; + while ($i < $num) { $obj = array_shift($tab_sqlobj); print ''; @@ -1002,27 +1002,27 @@ if ($socid > 0) if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) { print ''; } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) { print ''; } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) { print ''; } @@ -1034,13 +1034,13 @@ if ($socid > 0) } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } print ''; print ''; - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; } @@ -1065,7 +1065,7 @@ if ($socid > 0) dol_print_error($db); } - if($isCustomer) { + if ($isCustomer) { print ''; // class="ficheaddleft" print ''; // class="fichehalfright" print ''; // class="fichecenter" diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 79e7c11001c..d097b39b644 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -27,9 +27,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!$user->rights->commande->lire) accessforbidden(); @@ -42,7 +42,7 @@ $hookmanager->initHooks(array('ordersindex')); $langs->loadLangs(array('orders', 'bills')); // Security check -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); if ($user->socid > 0) { $action = ''; @@ -55,11 +55,11 @@ if ($user->socid > 0) * View */ -$commandestatic=new Commande($db); -$companystatic=new Societe($db); +$commandestatic = new Commande($db); +$companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); -$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; llxHeader("", $langs->trans("Orders"), $help_url); @@ -69,10 +69,10 @@ print load_fiche_titre($langs->trans("OrdersArea"), '', 'commercial'); print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search customer orders - $var=false; + $var = false; print ''; print ''; print '
'; @@ -89,14 +89,14 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele */ $sql = "SELECT count(c.rowid), c.fk_statut"; -$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.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('societe').")"; -if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " GROUP BY c.fk_statut"; +$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.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('societe').")"; +if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " GROUP BY c.fk_statut"; $resql = $db->query($sql); if ($resql) @@ -104,10 +104,10 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $total=0; - $totalinprocess=0; - $dataseries=array(); - $vals=array(); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $vals = array(); // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) while ($i < $num) { @@ -145,7 +145,7 @@ if ($resql) $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100%'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total?0:1); + print $dolgraph->show($total ? 0 : 1); print '
'; } @@ -155,7 +155,7 @@ if ($resql) { print ''; print ''; - print ''; @@ -175,22 +175,22 @@ else /* * Draft orders */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 0"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 0"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { print '
'; @@ -207,14 +207,14 @@ if (! empty($conf->commande->enabled)) { $obj = $db->fetch_object($resql); - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print '
'; print ''; print ''; print ''; 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 '
'.$langs->trans("Date").''.$langs->trans("Date").''.$langs->trans("ReasonDiscount").''.$langs->trans("ConsumedBy").''.$langs->trans("AmountHT").''.$langs->trans("MulticurrencyAmountHT").''.$langs->trans("VATRate").''.$langs->trans("AmountTTC").''.$langs->trans("MulticurrencyAmountTTC").' 
'; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; - $facturefournstatic->id=$obj->fk_invoice_supplier_source; - $facturefournstatic->ref=$obj->ref; - $facturefournstatic->type=$obj->type; + $facturefournstatic->id = $obj->fk_invoice_supplier_source; + $facturefournstatic->ref = $obj->ref; + $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''.price($obj->amount_ht).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ttc).'
'.$commandestatic->LibStatut($status, $bool, 0).''.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' '; + print ''.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' '; print $commandestatic->LibStatut($status, $bool, 3); print ''; print '
'; @@ -238,29 +238,29 @@ if (! empty($conf->commande->enabled)) print '
'; -$max=5; +$max = 5; /* * Last modified orders */ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; -$sql.= " s.nom as name, s.rowid as socid"; -$sql.= ", s.client"; -$sql.= ", s.code_client"; -$sql.= ", s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE c.fk_soc = s.rowid"; -$sql.= " AND c.entity IN (".getEntity('commande').")"; +$sql .= " s.nom as name, s.rowid as socid"; +$sql .= ", s.client"; +$sql .= ", s.code_client"; +$sql .= ", s.canvas"; +$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE c.fk_soc = s.rowid"; +$sql .= " AND c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut > 2"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " ORDER BY c.tms DESC"; -$sql.= $db->plimit($max, 0); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= " ORDER BY c.tms DESC"; +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
'; @@ -280,14 +280,14 @@ if ($resql) print '
'; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
'; @@ -299,9 +299,9 @@ if ($resql) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
'; @@ -324,23 +324,23 @@ else dol_print_error($db); /* * Orders to process */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.=" FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 1"; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 1"; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " ORDER BY c.rowid DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -359,14 +359,14 @@ if (! empty($conf->commande->enabled)) print '
'; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
'; @@ -378,9 +378,9 @@ if (! empty($conf->commande->enabled)) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
'; @@ -405,23 +405,23 @@ if (! empty($conf->commande->enabled)) /* * Orders thar are in a shipping process */ -if (! empty($conf->commande->enabled)) +if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; - $sql.= ", s.client"; - $sql.= ", s.code_client"; - $sql.= ", s.canvas"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND c.fk_statut = 2 "; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " ORDER BY c.rowid DESC"; + $sql .= ", s.client"; + $sql .= ", s.code_client"; + $sql .= ", s.canvas"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND c.fk_statut = 2 "; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " ORDER BY c.rowid DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -441,14 +441,14 @@ if (! empty($conf->commande->enabled)) print '
'; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
'; @@ -460,9 +460,9 @@ if (! empty($conf->commande->enabled)) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
'; diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index bc260a4e527..2af8ea7de22 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -26,13 +26,13 @@ * \brief Page de gestion des documents attaches a un compte bancaire */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.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 . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/bank.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.'/compta/bank/class/account.class.php'; -global $conf,$db,$langs; +global $conf, $db, $langs; // Load translation files required by the page $langs->loadLangs(array('banks', 'companies', 'other')); @@ -70,7 +70,7 @@ if (!$sortfield) $sortfield = "name"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); @@ -82,10 +82,10 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); if (!empty($num)) { $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); } $backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num; -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -100,7 +100,7 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output . "/".$id."/statement/" . dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num); // Onglets $head = account_statement_prepare_head($object, $num); @@ -111,13 +111,13 @@ if ($id > 0 || !empty($ref)) { $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } $morehtmlref = ''; - $title=$langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + $title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, '', 'title_bank.png'); @@ -125,8 +125,8 @@ if ($id > 0 || !empty($ref)) { print '
'; print ''; - print ''; - print ''; + print ''; + print ''; print "
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' .dol_print_size($totalsize, 1, 1).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
\n"; print ''; @@ -137,10 +137,10 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; - $param = '&id=' . $object->id.'&num='.$num; + $param = '&id='.$object->id.'&num='.$num; $uri = '&num='.$num; $relativepathwithnofile = $id."/statement/".$num."/"; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { dol_print_error($db); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 980cf6bd8f2..3baf50fcc2c 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -29,28 +29,28 @@ */ 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'); // Security check -$id = GETPOST("id", 'int') ? GETPOST("id", 'int'): GETPOST('ref', 'alpha'); +$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha'); $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; -$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); $object = new Account($db); $extrafields = new ExtraFields($db); @@ -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(); @@ -92,10 +92,10 @@ if ($action == 'add') $object->iban = trim($_POST["iban"]); $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alphanohtml'); + $account_number = GETPOST('account_number', 'alphanohtml'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; @@ -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); @@ -198,10 +198,10 @@ if ($action == 'update') $object->iban = trim($_POST["iban"]); $object->domiciliation = trim(GETPOST("domiciliation", "nohtml")); - $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); + $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); - $account_number = GETPOST('account_number', 'alpha'); + $account_number = GETPOST('account_number', 'alpha'); if (empty($account_number) || $account_number == '-1') { $object->account_number = ''; @@ -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(); } @@ -294,7 +294,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -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 '
'.$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 { @@ -420,7 +420,7 @@ if ($action == 'create') $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } @@ -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 ''; // Conciliate print ''; print ''; print ''; @@ -648,7 +648,7 @@ else // Accountancy code 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); @@ -625,18 +625,18 @@ else // Currency print '
'.$langs->trans("Currency").''; - $selectedcode=$object->currency_code; - if (! $selectedcode) $selectedcode=$conf->currency; + $selectedcode = $object->currency_code; + if (!$selectedcode) $selectedcode = $conf->currency; print $langs->trans("Currency".$selectedcode); 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 ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); + else print ($object->rappro == 1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); print '
'.$langs->trans("BalanceMinimalAllowed").'
'.$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).'
'; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -138,42 +138,42 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /** * Draft customers invoices */ -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; - $sql.= ", f.type"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", f.type"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) { $sql .= " AND f.fk_soc = $socid"; } // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); + $sql .= $hookmanager->resPrint; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
'; print '
'.$langs->trans("Search").'
'; print ''; - print ''; + print ''; if ($num) { - $companystatic=new Societe($db); + $companystatic = new Societe($db); $i = 0; $tot_ttc = 0; @@ -181,18 +181,18 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->id=$obj->rowid; - $facturestatic->ref=$obj->ref; - $facturestatic->date=$db->jdate($obj->date); - $facturestatic->type=$obj->type; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->ref_client=$obj->ref_client; + $facturestatic->id = $obj->rowid; + $facturestatic->ref = $obj->ref; + $facturestatic->date = $db->jdate($obj->date); + $facturestatic->type = $obj->type; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->ref_client = $obj->ref_client; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->email=$obj->email; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; $companystatic->client = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; @@ -207,7 +207,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; print ''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -231,36 +231,36 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) /** * Draft suppliers invoices */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); + $sql .= $hookmanager->resPrint; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); print '
'; print '
'.$langs->trans("CustomersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("CustomersDraftInvoices").($num ? ' '.$num.'' : '').'
'.price($obj->total_ttc).'
'; print ''; - print ''; + print ''; if ($num) { - $companystatic=new Societe($db); + $companystatic = new Societe($db); $i = 0; $tot_ttc = 0; @@ -268,19 +268,19 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facturesupplierstatic->ref=$obj->ref; - $facturesupplierstatic->id=$obj->rowid; - $facturesupplierstatic->total_ht=$obj->total_ht; - $facturesupplierstatic->total_tva=$obj->total_tva; - $facturesupplierstatic->total_ttc=$obj->total_ttc; - $facturesupplierstatic->ref_supplier=$obj->ref_supplier; - $facturesupplierstatic->type=$obj->type; + $facturesupplierstatic->ref = $obj->ref; + $facturesupplierstatic->id = $obj->rowid; + $facturesupplierstatic->total_ht = $obj->total_ht; + $facturesupplierstatic->total_tva = $obj->total_tva; + $facturesupplierstatic->total_ttc = $obj->total_ttc; + $facturesupplierstatic->ref_supplier = $obj->ref_supplier; + $facturesupplierstatic->type = $obj->type; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->email=$obj->email; - $companystatic->country_id=$obj->country_id; - $companystatic->country_code=$obj->country_code; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; $companystatic->fournisseur = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; @@ -295,7 +295,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -321,35 +321,35 @@ print '
'; // Latest modified customer invoices -if (! empty($conf->facture->enabled) && $user->rights->facture->lire) +if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $langs->load("boxes"); - $facstatic=new Facture($db); + $facstatic = new Facture($db); $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; - $sql.= ", f.date_lim_reglement as datelimite"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client, s.code_compta, s.email"; - $sql.= ", cc.rowid as country_id, cc.code as country_code"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = f.fk_soc"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta, s.email"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = f.fk_soc"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerLastModified', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; - $sql.= " cc.rowid, cc.code"; - $sql.= " ORDER BY f.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; + $sql .= " cc.rowid, cc.code"; + $sql .= " ORDER BY f.tms DESC "; + $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) @@ -360,7 +360,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; print '
'.$langs->trans("SuppliersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("SuppliersDraftInvoices").($num ? ' '.$num.'' : '').'
'.price($obj->total_ttc).'
'; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -372,22 +372,22 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->statut = $obj->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $facturestatic->type=$obj->type; + $facturestatic->type = $obj->type; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->country_id=$obj->country_id; - $thirdpartystatic->country_code=$obj->country_code; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->client=1; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->country_id = $obj->country_id; + $thirdpartystatic->country_code = $obj->country_code; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->client = 1; $thirdpartystatic->code_client = $obj->code_client; //$thirdpartystatic->code_fournisseur = $obj->code_fournisseur; $thirdpartystatic->code_compta = $obj->code_compta; @@ -406,9 +406,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } print ''; print '
'.$langs->trans("BoxTitleLastCustomerBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' '; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '
'; @@ -416,23 +416,23 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'
'.$langs->trans("NoInvoice").'

'; @@ -447,34 +447,34 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) // Last modified supplier invoices -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $langs->load("boxes"); - $facstatic=new FactureFournisseur($db); + $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", SUM(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - $sql.= " AND ff.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql.= " AND ff.fk_soc = ".$socid; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", SUM(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierLastModified', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierLastModified', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; - $sql.= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= " ORDER BY ff.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; + $sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.tms DESC "; + $sql .= $db->plimit($max, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -482,7 +482,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print '
'; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -495,15 +495,15 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facstatic->ref=$obj->ref; + $facstatic->ref = $obj->ref; $facstatic->id = $obj->rowid; $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->fournisseur=1; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->fournisseur = 1; //$thirdpartystatic->code_client = $obj->code_client; $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; //$thirdpartystatic->code_compta = $obj->code_compta; @@ -515,21 +515,21 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; $total += $obj->total_ht; - $total_ttc += $obj->total_ttc; - $totalam += $obj->am; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; $i++; } } else { - $colspan=5; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 5; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
'.$langs->trans("BoxTitleLastSupplierBills", $max).''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' '; print $thirdpartystatic->getNomUrl(1, 'supplier', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'
'.$langs->trans("NoInvoice").'

'; @@ -543,28 +543,28 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- // Last donations -if (! empty($conf->don->enabled) && $user->rights->societe->lire) +if (!empty($conf->don->enabled) && $user->rights->societe->lire) { include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("boxes"); - $donationstatic=new Don($db); + $donationstatic = new Don($db); $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; - $sql.= " WHERE d.entity IN (".getEntity('donation').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."don as d"; + $sql .= " WHERE d.entity IN (".getEntity('donation').")"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereLastDonations', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereLastDonations', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= $db->order("d.tms", "DESC"); - $sql.= $db->plimit($max, 0); + $sql .= $db->order("d.tms", "DESC"); + $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var=false; + $var = false; $num = $db->num_rows($result); $i = 0; @@ -586,13 +586,13 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire) { $objp = $db->fetch_object($result); - $donationstatic->id=$objp->rowid; - $donationstatic->ref=$objp->rowid; - $donationstatic->lastname=$objp->lastname; - $donationstatic->firstname=$objp->firstname; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; - $label=$donationstatic->getFullName($langs); - if ($objp->societe) $label.=($label?' - ':'').$objp->societe; + $label = $donationstatic->getFullName($langs); + if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe; print '
'.$donationstatic->getNomUrl(1).'
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -655,15 +655,15 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if ($num) { $i = 0; - $tot_ttc=0; + $tot_ttc = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $chargestatic->id=$obj->rowid; - $chargestatic->ref=$obj->rowid; - $chargestatic->label=$obj->label; - $chargestatic->paye=$obj->paye; + $chargestatic->id = $obj->rowid; + $chargestatic->ref = $obj->rowid; + $chargestatic->label = $obj->label; + $chargestatic->paye = $obj->paye; print ''; print ''; @@ -673,7 +673,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''; print ''; - $tot_ttc+=$obj->amount; + $tot_ttc += $obj->amount; $i++; } @@ -700,37 +700,37 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) /* * Customers orders to be billed */ -if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) +if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user->rights->commande->lire && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - $commandestatic=new Commande($db); + $commandestatic = new Commande($db); $langs->load("orders"); $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; - $sql.= ", s.nom as name, s.email"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; - $sql.= " cc.rowid as country_id, cc.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= " AND c.fk_statut = 3"; - $sql.= " AND c.facture = 0"; + $sql .= ", s.nom as name, s.email"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; + $sql .= " cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_statut = 3"; + $sql .= " AND c.facture = 0"; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; + $sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); @@ -742,31 +742,31 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print '
'.$langs->trans("ContributionsToPay").($num?' '.$num.'':'').''.$langs->trans("ContributionsToPay").($num ? ' '.$num.'' : '').''.$langs->trans("DateDue").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").'
'.$chargestatic->getNomUrl(1).''.$chargestatic->getLibStatut(3).'
'; print ""; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; - $tot_ht=$tot_ttc=$tot_tobill=0; + $tot_ht = $tot_ttc = $tot_tobill = 0; $societestatic = new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->country_id=$obj->country_id; - $societestatic->country_code=$obj->country_code; - $societestatic->client=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; $societestatic->code_client = $obj->code_client; //$societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; //$societestatic->code_fournisseur = $obj->code_fournisseur; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; print ''; print ''; print '
'.$langs->trans("OrdersDeliveredToBill").' '.$num.''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("ToBill").' 
'; @@ -779,9 +779,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print ' '; print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print '
'; @@ -790,20 +790,20 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print '
'; print $societestatic->getNomUrl(1, 'customer', 44); print ''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc-$obj->tot_fttc).''.price($obj->total_ttc - $obj->tot_fttc).''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') '.price($tot_ht).''.price($tot_ht).''.price($tot_ttc).''.price($tot_tobill).' 
'; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -871,21 +871,21 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->type=$obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_tva; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->type = $obj->type; $facturestatic->statut = $obj->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->country_id=$obj->country_id; - $societestatic->country_code=$obj->country_code; - $societestatic->client=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; $societestatic->code_client = $obj->code_client; $societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; @@ -904,33 +904,33 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) } print ''; print '
'.$langs->trans("BillsCustomersUnpaid", $num).' '.$num.''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").' '; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '
'; print '
' ; + print ''; print $societestatic->getNomUrl(1, 'customer', 44); print ''.dol_print_date($db->jdate($obj->datelimite), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
'.$langs->trans("NoInvoice").'

'; @@ -954,36 +954,36 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) /* * Unpayed supplier invoices */ -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $facstatic=new FactureFournisseur($db); + $facstatic = new FactureFournisseur($db); $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; - $sql.= ", ff.date_lim_reglement"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid, s.email"; - $sql.= ", s.code_client, s.code_compta"; - $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - $sql.= " AND ff.entity = ".$conf->entity; - $sql.= " AND ff.paye = 0"; - $sql.= " AND ff.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql.= " AND ff.fk_soc = ".$socid; + $sql .= ", ff.date_lim_reglement"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.paye = 0"; + $sql .= " AND ff.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND ff.fk_soc = ".$socid; // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); - $sql.=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); + $sql .= $hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; - $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql.= " ORDER BY ff.date_lim_reglement ASC"; + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.date_lim_reglement ASC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -992,7 +992,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -1006,17 +1006,17 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - $facstatic->ref=$obj->ref; + $facstatic->ref = $obj->ref; $facstatic->id = $obj->rowid; $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->email=$obj->email; - $societestatic->client=0; - $societestatic->fournisseur=1; + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->client = 0; + $societestatic->fournisseur = 1; $societestatic->code_client = $obj->code_client; $societestatic->code_fournisseur = $obj->code_fournisseur; $societestatic->code_compta = $obj->code_compta; @@ -1027,20 +1027,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''; print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; print ''; $total += $obj->total_ht; - $total_ttc += $obj->total_ttc; - $totalam += $obj->am; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; $i++; } - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; print ''; @@ -1048,8 +1048,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- } else { - $colspan=6; - if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } print '
'.$langs->trans("BillsSuppliersUnpaid", $num).' '.$num.''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").' '.$societestatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').''.price($obj->total_ht).''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')
'.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total).''.price($total_ttc).''.price($totalam).' 
'.$langs->trans("NoInvoice").'

'; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 6ccb76e95e5..64a116c5ae4 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); -$mode=GETPOST("mode", 'alpha'); -$year=GETPOST("year", 'int'); -$filtre=GETPOST("filtre", 'alpha'); -if (! $year && $mode != 'sconly') { $year=date("Y", time()); } +$mode = GETPOST("mode", 'alpha'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'sconly') { $year = date("Y", time()); } -$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'); @@ -53,8 +53,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="pc.datep"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "pc.datep"; +if (!$sortorder) $sortorder = "DESC"; /* @@ -62,21 +62,21 @@ if (! $sortorder) $sortorder="DESC"; */ $tva_static = new Tva($db); -$socialcontrib=new ChargeSociales($db); -$payment_sc_static=new PaymentSocialContribution($db); +$socialcontrib = new ChargeSociales($db); +$payment_sc_static = new PaymentSocialContribution($db); $sal_static = new PaymentSalary($db); llxHeader('', $langs->trans("SpecialExpensesArea")); -$title=$langs->trans("SpecialExpensesArea"); -if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments"); +$title = $langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($mode == 'sconly') $param='&mode=sconly'; -if ($sortfield) $param.='&sortfield='.$sortfield; -if ($sortorder) $param.='&sortorder='.$sortorder; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'sconly') $param = '&mode=sconly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; print '
'; @@ -90,7 +90,7 @@ print ''; if ($mode != 'sconly') { - $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } else @@ -98,7 +98,7 @@ else print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } -if ($year) $param.='&year='.$year; +if ($year) $param .= '&year='.$year; if ($mode != 'sconly') { @@ -106,12 +106,12 @@ if ($mode != 'sconly') print "
"; } -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only if ($mode != 'sconly') { - print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); } print ''; @@ -127,15 +127,15 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print "\n"; $sql = "SELECT c.id, c.libelle as type_label,"; - $sql.= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; - $sql.= " pct.code as payment_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; - $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,"; - $sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; - $sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; - $sql.= " AND cs.entity = ".$conf->entity; + $sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; + $sql .= " pct.code as payment_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs,"; + $sql .= " ".MAIN_DB_PREFIX."paiementcharge as pc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql .= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; + $sql .= " AND cs.entity = ".$conf->entity; if ($year > 0) { $sql .= " AND ("; @@ -145,12 +145,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } - if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); //$sql.= $db->plimit($limit+1,$offset); //print $sql; dol_syslog("compta/sociales/payments.php: select payment", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -163,8 +163,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $obj = $db->fetch_object($resql); - $payment_sc_static->id=$obj->pid; - $payment_sc_static->ref=$obj->pid; + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; print ''; // Ref payment @@ -177,16 +177,16 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $obj->num_payment.''; // Label print ''; // Type print ''; // Date - $date=$obj->periode; - if (empty($date)) $date=$obj->date_ech; + $date = $obj->periode; + if (empty($date)) $date = $obj->date_ech; print ''; // Expected to pay print ''; @@ -202,7 +202,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $i++; } print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print ''; @@ -217,33 +217,33 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // VAT -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
"; $tva = new Tva($db); - print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
'; - $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->rowid; - $socialcontrib->label=$obj->label; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = $obj->rowid; + $socialcontrib->label = $obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.$obj->type_label.''.dol_print_date($date, 'day').''.price($obj->total).'
'.$langs->trans("Total").'   
'; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -268,8 +268,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -296,55 +296,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // Localtax -if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { - $j=1; - $numlt=3; + $j = 1; + $numlt = 3; } -elseif($mysoc->localtax1_assuj=="1") +elseif ($mysoc->localtax1_assuj == "1") { - $j=1; - $numlt=2; + $j = 1; + $numlt = 2; } -elseif($mysoc->localtax2_assuj=="1") +elseif ($mysoc->localtax2_assuj == "1") { - $j=2; - $numlt=3; + $j = 2; + $numlt = 3; } else { - $j=0; - $numlt=0; + $j = 0; + $numlt = 0; } -while($j<$numlt) +while ($j < $numlt) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
"; $tva = new Tva($db); - print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."
'; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); @@ -369,8 +369,8 @@ while($j<$numlt) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -399,33 +399,33 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { $sal = new PaymentSalary($db); print "
"; - print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user').")"; - $sql.= " AND u.rowid = s.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; if ($year > 0) { - $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; } - if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."
'; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -448,11 +448,11 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print "\n"; - print '"; + print '"; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -462,7 +462,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $i++; } print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print '"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index f72edeb3a34..741d106ab48 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -48,12 +48,12 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'users', 'other', 'commercial')); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); -$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); -$confirm = GETPOST('confirm', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$id = GETPOST('id', 'int'); +$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); +$confirm = GETPOST('confirm', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); $object = new Contact($db); @@ -66,9 +66,9 @@ $socialnetworks = getArrayOfSocialNetworks(); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); -$objcanvas=null; -$canvas = (! empty($object->canvas)?$object->canvas:GETPOST("canvas")); -if (! empty($canvas)) +$objcanvas = null; +$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -120,30 +120,30 @@ if (empty($reshook)) // Creation user $nuser = new User($db); - $result=$nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) + $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha) if ($result > 0) { - $result2=$nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) + $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) if ($result2) { $db->commit(); } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$nuser->error; $errors=$nuser->errors; + $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); } } else { - $error=$object->error; $errors=$object->errors; + $error = $object->error; $errors = $object->errors; } } @@ -152,7 +152,7 @@ if (empty($reshook)) if ($action == 'disable') { $object->fetch($id); - if ($object->setstatus(0)<0) + if ($object->setstatus(0) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -167,7 +167,7 @@ if (empty($reshook)) if ($action == 'enable') { $object->fetch($id); - if ($object->setstatus(1)<0) + if ($object->setstatus(1) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,41 +183,41 @@ if (empty($reshook)) { $db->begin(); - if ($canvas) $object->canvas=$canvas; + if ($canvas) $object->canvas = $canvas; - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); $object->civility_code = GETPOST("civility_code", 'alpha'); $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->state_id = GETPOST("state_id", 'int'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); + $object->country_id = GETPOST("country_id", 'int'); + $object->state_id = GETPOST("state_id", 'int'); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); //$object->twitter = GETPOST("twitter", 'alpha'); //$object->facebook = GETPOST("facebook", 'alpha'); //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } } - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); $object->statut = 1; //Defult status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. @@ -232,18 +232,18 @@ if (empty($reshook)) $action = 'create'; } - if (! GETPOST("lastname")) + if (!GETPOST("lastname")) { - $error++; $errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - if (! $error) + if (!$error) { - $id = $object->create($user); + $id = $object->create($user); if ($id <= 0) { - $error++; $errors=array_merge($errors, ($object->error?array($object->error):$object->errors)); + $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; } else { // Categories association @@ -253,26 +253,26 @@ if (empty($reshook)) // Add mass emailing flag into table mailing_unsubscribe if (GETPOST('no_email', 'int') && $object->email) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql=$db->query($sql); + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if (empty($obj->nb)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql=$db->query($sql); + $resql = $db->query($sql); } } } } } - if (! $error && $id > 0) + if (!$error && $id > 0) { $db->commit(); - if (! empty($backtopage)) $url=$backtopage; - else $url='card.php?id='.$id; + if (!empty($backtopage)) $url = $backtopage; + else $url = 'card.php?id='.$id; header("Location: ".$url); exit; } @@ -284,10 +284,10 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) { - $result=$object->fetch($id); + $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); + $object->old_lastname = GETPOST("old_lastname"); $object->old_firstname = GETPOST("old_firstname"); $result = $object->delete(); @@ -310,17 +310,17 @@ if (empty($reshook)) } } - if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { if (empty($_POST["lastname"])) { - $error++; $errors=array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } - if (! $error) + if (!$error) { - $contactid=GETPOST("contactid", 'int'); + $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); // Photo save @@ -328,8 +328,8 @@ if (empty($reshook)) $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->photo) { - $fileimg=$dir.'/'.$object->photo; - $dirthumbs=$dir.'/thumbs'; + $fileimg = $dir.'/'.$object->photo; + $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); $object->photo = ''; @@ -342,10 +342,10 @@ if (empty($reshook)) if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -365,7 +365,7 @@ if (empty($reshook)) } else { - switch($_FILES['photo']['error']) + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form @@ -379,49 +379,49 @@ if (empty($reshook)) $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname", 'alpha'); - $object->old_firstname = GETPOST("old_firstname", 'alpha'); + $object->old_lastname = GETPOST("old_lastname", 'alpha'); + $object->old_firstname = GETPOST("old_firstname", 'alpha'); - $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); + $object->socid = GETPOST("socid", 'int'); + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); + $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); + $object->address = GETPOST("address", 'alpha'); + $object->zip = GETPOST("zipcode", 'alpha'); + $object->town = GETPOST("town", 'alpha'); $object->state_id = GETPOST("state_id", 'int'); $object->country_id = GETPOST("country_id", 'int'); - $object->email = GETPOST("email", 'alpha'); - $object->no_email = GETPOST("no_email", "int"); + $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); //$object->twitter = GETPOST("twitter", 'alpha'); //$object->facebook = GETPOST("facebook", 'alpha'); //$object->linkedin = GETPOST("linkedin", 'alpha'); - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } } - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + $object->phone_pro = GETPOST("phone_pro", 'alpha'); + $object->phone_perso = GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); + $object->fax = GETPOST("fax", 'alpha'); + $object->priv = GETPOST("priv", 'int'); + $object->note_public = GETPOST("note_public", 'none'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->update($contactid, $user); @@ -437,30 +437,30 @@ if (empty($reshook)) { if ($no_email) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; - $resql=$db->query($sql); + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; if (empty($noemail)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; - $resql=$db->query($sql); + $resql = $db->query($sql); } } } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); - $resql=$db->query($sql); + $resql = $db->query($sql); } $object->no_email = $no_email; } - $object->old_lastname=''; - $object->old_firstname=''; + $object->old_lastname = ''; + $object->old_firstname = ''; $action = 'view'; } else @@ -471,9 +471,9 @@ if (empty($reshook)) } } - if (! $error && empty($errors)) + if (!$error && empty($errors)) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -482,9 +482,9 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name='CONTACT_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromcontact'; + $trigger_name = 'CONTACT_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromcontact'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -494,15 +494,15 @@ if (empty($reshook)) */ -$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname; -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $form = new Form($db); $formcompany = new FormCompany($db); -$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($socid > 0) { @@ -518,11 +518,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) if (empty($object->error) && $id) { $object = new Contact($db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } - $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { @@ -535,27 +535,27 @@ else { if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage?'&backtopage='.$backtopage:''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } /* * Onglets */ - $head=array(); + $head = array(); if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); - $res=$object->fetch($id, $user); - if ($res<0) { + $res = $object->fetch($id, $user); + if ($res < 0) { setEventMessages($object->error, $object->errors, 'errors'); } // Show tabs $head = contact_prepare_head($object); - $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } if ($user->rights->societe->contact->creer) @@ -565,25 +565,25 @@ else /* * Fiche en mode creation */ - $object->canvas=$canvas; + $object->canvas = $canvas; $object->state_id = GETPOST("state_id"); // We set country_id, country_code and label for the selected country - $object->country_id=$_POST["country_id"]?GETPOST("country_id"):(empty($objsoc->country_id)?$mysoc->country_id:$objsoc->country_id); + $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); if ($object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); + $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; } - $title = $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - $linkback=''; + $title = $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $linkback = ''; print load_fiche_titre($title, $linkback, 'address'); // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); if ($conf->use_javascript_ajax) { @@ -612,7 +612,7 @@ else print ''; print ''; print ''; - if (! empty($objsoc)) { + if (!empty($objsoc)) { print ''; } @@ -622,9 +622,9 @@ else // Name print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -647,23 +647,23 @@ else // Civility print ''; print ''; - print ''; + print ''; - $colspan=3; - if ($conf->use_javascript_ajax && $socid > 0) $colspan=2; + $colspan = 3; + if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2; // Address - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party print ''; - print ''; + print ''; if ($conf->use_javascript_ajax && $socid > 0) { - $rowspan=3; + $rowspan = 3; if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; print ''; // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; } - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party // Phone / Fax print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; - if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party // Email print ''; - print ''; - if (! empty($conf->mailing->enabled)) + print ''; + if (!empty($conf->mailing->enabled)) { $noemail = ''; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } print ''; - print ''; + print ''; } else { @@ -752,13 +752,13 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -802,13 +802,13 @@ else // Visibility print ''; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print '"; @@ -816,7 +816,7 @@ else // Contact by default if (!empty($socid)) { - print ''; + print ''; print '
".$obj->label."'.($obj->salary?price($obj->salary):'')."'.($obj->salary ?price($obj->salary) : '')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day')."
'.$langs->trans("Total").'  '.price($total)."
lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">firstname).'">
firstname).'">
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility_code", 'alpha'):$object->civility_code, 'civility_code'); + print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code'); print '
poste).'">poste).'">
'; @@ -673,23 +673,23 @@ else print '
/ '; - print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha')?GETPOST("zipcode", 'alpha'):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((GETPOST("town", 'alpha')?GETPOST("town", 'alpha'):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha') ?GETPOST("zipcode", 'alpha') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((GETPOST("town", 'alpha') ?GETPOST("town", 'alpha') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'; - print $form->select_country((GETPOST("country_id", 'alpha')?GETPOST("country_id", 'alpha'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST("country_id", 'alpha') ?GETPOST("country_id", 'alpha') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
'; } @@ -700,7 +700,7 @@ else if ($object->country_id) { - print $formcompany->select_state(GETPOST("state_id", 'alpha')?GETPOST("state_id", 'alpha'):$object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOST("state_id", 'alpha') ?GETPOST("state_id", 'alpha') : $object->state_id, $object->country_code, 'state_id'); } else { @@ -709,42 +709,42 @@ else print '
'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).'
'.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''.$form->selectyesno('no_email', (GETPOSTISSET("no_email")?GETPOST("no_email", 'alpha'):$noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'; - print ''; + print ''; print '
'; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha')?GETPOST("priv", 'alpha'):$object->priv), 0); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); print '
' . $form->editfieldkey('Categories', 'contcats', '', $object, 0) . ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print '
'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); print $form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%'); print "
' . $langs->trans("ContactByDefaultFor") . '
'.$langs->trans("ContactByDefaultFor").''; $contactType = $object->listeTypeContacts('external', '', 1); print $form->multiselectarray('roles', $contactType); @@ -824,8 +824,8 @@ else } // Other attributes - $parameters=array('socid' => $socid, 'objsoc' => $objsoc, '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('socid' => $socid, 'objsoc' => $objsoc, '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)) { @@ -843,7 +843,7 @@ else // Date To Birth print '
'; - $form=new Form($db); + $form = new Form($db); if ($object->birthday) { print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0); @@ -871,7 +871,7 @@ else print '
'; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -879,13 +879,13 @@ else else { print '     '; - print ''; + print ''; } print '
'; print ""; } - elseif ($action == 'edit' && ! empty($id)) + elseif ($action == 'edit' && !empty($id)) { /* * Fiche en mode edition @@ -894,16 +894,16 @@ else // We set country_id, and country_code label of the chosen country if (isset($_POST["country_id"]) || $object->country_id) { - $tmparray=getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; + $tmparray = getCountry($object->country_id, 'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } $objsoc = new Societe($db); $objsoc->fetch($object->socid); // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); if ($conf->use_javascript_ajax) { @@ -935,14 +935,14 @@ else print ''; print ''; print ''; - if (! empty($backtopage)) print ''; + if (!empty($backtopage)) print ''; dol_fiche_head($head, 'card', $title, 0, 'contact'); print ''; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; - print ''; + print ''; print ''; print ''; // Firstname print ''; - print ''; + print ''; print ''; // Company @@ -964,24 +964,24 @@ else { print ''; print ''; print ''; } // Civility print ''; print ''; - print ''; + print ''; // Address print ''; print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; } // Phone print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; // EMail - print ''; - print ''; - if (! empty($conf->mailing->enabled)) + print ''; + print ''; + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''; @@ -1043,23 +1043,23 @@ else // Unsubscribe print ''; - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $noemail = ''; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } print ''; - print ''; + print ''; } else { @@ -1067,13 +1067,13 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -1117,7 +1117,7 @@ else // Visibility print ''; @@ -1141,7 +1141,7 @@ else // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''; + print ''; print ''; + print ''; 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)) { @@ -1172,31 +1172,31 @@ else $object->load_ref_elements(); - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { print ''; } - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } @@ -1204,8 +1204,8 @@ else print ''; // Email - if (! empty($conf->mailing->enabled)) + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); print ''; @@ -1325,14 +1325,14 @@ else { //print 'eee'.$object->email; $noemail = $object->no_email; - if (empty($noemail) && ! empty($object->email)) + if (empty($noemail) && !empty($object->email)) { - $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'"; //print $sql; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $noemail = $obj->nb; } } @@ -1352,15 +1352,15 @@ else print '
'.$langs->trans("ID").''; print $object->ref; @@ -951,12 +951,12 @@ else // Lastname print '
lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">
firstname).'">firstname).'">
'; - print $form->select_company(GETPOST('socid', 'int')?GETPOST('socid', 'int'):($object->socid?$object->socid:-1), 'socid', '', $langs->trans("SelectThirdParty")); + print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); print '
'; - print $formcompany->select_civility(GETPOSTISSET("civility_code")?GETPOST("civility", "aZ09"):$object->civility_code, 'civility_code'); + print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility", "aZ09") : $object->civility_code, 'civility_code'); print '
poste).'">
poste).'">
'; print '
'; - print ''; + print ''; print '
'; if ($conf->use_javascript_ajax) print ''.$langs->trans('CopyAddressFromSoc').'
'; print '
'; @@ -989,20 +989,20 @@ else // Zip / Town print '
/ '; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode"):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6).' '; - print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town"):$object->town), 'town', array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["zipcode"]) ?GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6).' '; + print $formcompany->select_ziptown((isset($_POST["town"]) ?GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'; - print $form->select_country(isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'country_id'); + print $form->select_country(isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
'; } @@ -1011,25 +1011,25 @@ else print '
'; } - print $formcompany->select_state(GETPOSTISSET('state_id')?GETPOST('state_id', 'alpha'):$object->state_id, $object->country_code, 'state_id'); + print $formcompany->select_state(GETPOSTISSET('state_id') ?GETPOST('state_id', 'alpha') : $object->state_id, $object->country_code, 'state_id'); print '
'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).'
'.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''.$langs->trans("NbOfEMailingsSend").'
'.$form->selectyesno('no_email', (GETPOSTISSET("no_email")?GETPOST("no_email", 'alpha'):$noemail), 1).''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'
'; - print ''; + print ''; print '
'; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); print $form->selectarray('priv', $selectarray, $object->priv, 0); print '
' . $form->editfieldkey('Categories', 'contcats', '', $object, 0) . '
'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1); $c = new Categorie($db); @@ -1155,15 +1155,15 @@ else // Contact by default if (!empty($object->socid)) { - print '
' . $langs->trans("ContactByDefaultFor") . '
'.$langs->trans("ContactByDefaultFor").''; print $formcompany->showRoles("roles", $object, 'edit', $object->roles); print '
'.$langs->trans("ContactForOrders").''; - print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder"); + print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder"); print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
'.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1242,14 +1242,14 @@ else } } - if (! empty($id) && $action != 'edit' && $action != 'create') + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); // View mode // Show errors - dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); + dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); dol_fiche_head($head, 'card', $title, -1, 'contact'); @@ -1257,15 +1257,15 @@ else { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $login=dol_buildlogin($object->lastname, $object->firstname); + $login = dol_buildlogin($object->lastname, $object->firstname); - $generated_password=''; - if (! $ldap_sid) // TODO ldap_sid ? + $generated_password = ''; + if (!$ldap_sid) // TODO ldap_sid ? { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(false); + $generated_password = getRandomPassword(false); } - $password=$generated_password; + $password = $generated_password; // Create a form array $formquestion = array( @@ -1273,27 +1273,27 @@ else array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password), //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External'))) ); - $text=$langs->trans("ConfirmCreateContact").'
'; - if (! empty($conf->societe->enabled)) + $text = $langs->trans("ConfirmCreateContact").'
'; + if (!empty($conf->societe->enabled)) { - if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser"); - else $text.=$langs->trans("UserWillBeInternalUser"); + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); } print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($object->socid); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : '; - if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact'); - else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -1313,7 +1313,7 @@ else print '
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("NbOfEMailingsSend").'
'; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print ''; + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + print ''; print ''; } if (!empty($object->socid)) { - print ''; + print ''; print ''; @@ -1368,49 +1368,49 @@ else // Other attributes $cols = 3; - $parameters=array('socid'=>$socid); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object->load_ref_elements(); - if (! empty($conf->propal->enabled)) + if (!empty($conf->propal->enabled)) { print ''; } - if (! empty($conf->commande->enabled) || ! empty($conf->expedition->enabled)) + if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) { print ''; } - if (! empty($conf->contrat->enabled)) + if (!empty($conf->contrat->enabled)) { print ''; } - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { print ''; } 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 } @@ -915,17 +915,17 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $extrafields->fetch_name_optionals_label($contactstatic->table_element); - $contactstatic->fields=array( - 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), - 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + $contactstatic->fields = array( + 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list - $arrayfields=array( - 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1), + $arrayfields = array( + 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1), 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), @@ -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".'
' . $langs->trans("Categories") . '
'.$langs->trans("Categories").''; print $form->showCategories($object->id, 'contact', 1); print '
' . $langs->trans("ContactByDefaultFor") . '
'.$langs->trans("ContactByDefaultFor").''; print $formcompany->showRoles("roles", $object, 'view'); print '
'.$langs->trans("ContactForProposals").''; - print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print '
'; - if (! empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } + if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); print ''; - $none=$langs->trans("NoContactForAnyOrder"); - if (! empty($conf->expedition->enabled)) { $none=$langs->trans("NoContactForAnyOrderOrShipments"); } - print $object->ref_commande?$object->ref_commande:$none; + $none = $langs->trans("NoContactForAnyOrder"); + if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); } + print $object->ref_commande ? $object->ref_commande : $none; print '
'.$langs->trans("ContactForContracts").''; - print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print '
'.$langs->trans("ContactForInvoices").''; - print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print '
'.$langs->trans("DolibarrLogin").''; if ($object->user_id) { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($object->user_id); + $dolibarr_user = new User($db); + $result = $dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); @@ -1434,11 +1434,11 @@ else // Barre d'actions print '
'; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && $action!='presend') + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && $action != 'presend') { - if (! empty($object->email)) + if (!empty($object->email)) { $langs->load("mails"); print ''; @@ -1454,7 +1454,7 @@ else print ''.$langs->trans('Modify').''; } - if (! $object->user_id && $user->rights->user->user->creer) + if (!$object->user_id && $user->rights->user->user->creer) { print ''.$langs->trans("CreateDolibarrLogin").''; } @@ -1473,15 +1473,15 @@ else // Delete if ($user->rights->societe->contact->supprimer) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } } print "
"; // Presend form - $modelmail='contact'; - $defaulttopic='Information'; + $modelmail = 'contact'; + $defaulttopic = 'Information'; $diroutput = $conf->contact->dir_output; $trackid = 'con'.$object->id; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 358a823dd12..fb9c607eb72 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -38,42 +38,42 @@ function bank_prepare_head(Account $object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'bankname'; $h++; - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries_list.php?id=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/bankentries_list.php?id=".$object->id; $head[$h][1] = $langs->trans("BankTransactions"); $head[$h][2] = 'journal'; $h++; // if ($conf->global->MAIN_FEATURES_LEVEL >= 1) // { - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$object->id; $head[$h][1] = $langs->trans("PlannedTransactions"); $head[$h][2] = 'cash'; $h++; // } - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$object->id; $head[$h][1] = $langs->trans("IOMonthlyReporting"); $head[$h][2] = 'annual'; $h++; - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$object->id; $head[$h][1] = $langs->trans("Graph"); $head[$h][2] = 'graph'; $h++; if ($object->courant != Account::TYPE_CASH) { - $nbReceipts=0; + $nbReceipts = 0; // List of all standing receipts $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.fk_account = ".$object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.fk_account = ".$object->id; $resql = $db->query($sql); if ($resql) @@ -85,7 +85,7 @@ function bank_prepare_head(Account $object) $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; $head[$h][1] = $langs->trans("AccountStatements"); - if (($nbReceipts) > 0) $head[$h][1].= ''.($nbReceipts).''; + if (($nbReceipts) > 0) $head[$h][1] .= ''.($nbReceipts).''; $head[$h][2] = 'statement'; $h++; } @@ -93,12 +93,12 @@ function bank_prepare_head(Account $object) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; + $nbLinks = Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT."/compta/bank/document.php?account=".$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -129,12 +129,12 @@ function bank_admin_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/bank.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/chequereceipts.php'; $head[$h][1] = $langs->trans("CheckReceiptShort"); $head[$h][2] = 'checkreceipts'; $h++; @@ -167,11 +167,11 @@ function bank_admin_prepare_head($object) */ function account_statement_prepare_head($object, $num) { - global $langs, $conf, $user,$db; + global $langs, $conf, $user, $db; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/compta/bank/releve.php?account=' . $object->id.'&num='.$num; + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$object->id.'&num='.$num; $head[$h][1] = $langs->trans("AccountStatements"); $head[$h][2] = 'statement'; $h++; @@ -179,13 +179,13 @@ function account_statement_prepare_head($object, $num) // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . $object->id.'/'.dol_sanitizeFileName($num); + $upload_dir = $conf->bank->dir_output."/".$object->id.'/'.dol_sanitizeFileName($num); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/account_statement_document.php?account=" . $object->id."&num=".$num; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' '.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -223,12 +223,12 @@ function various_payment_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; @@ -293,12 +293,12 @@ function checkBanForAccount($account) if (empty($account->cle)) $account->cle = $account->cle_rib; - dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG); + dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); if ($country_code == 'FR') { // France rules $coef = array(62, 34, 3); // Concatenation des differents codes. - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet) . trim($account->number) . trim($account->cle)); + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle)); // On remplace les eventuelles lettres par des chiffres. //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz", "12345678912345678923456789"); @@ -322,7 +322,7 @@ function checkBanForAccount($account) if ($country_code == 'ES') { // Spanish rules $CCC = strtolower(trim($account->number)); - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet)); + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet)); $cle_rib = strtolower(checkES($rib, $CCC)); if ($cle_rib == strtolower($account->cle)) { return true; @@ -364,7 +364,7 @@ function checkES($IentOfi, $InumCta) return $keycontrol; } - $ccc = $IentOfi . $InumCta; + $ccc = $IentOfi.$InumCta; $numbers = "1234567890"; $i = 0; @@ -396,7 +396,7 @@ function checkES($IentOfi, $InumCta) $sum = 0; for ($i = 0; $i < 11; $i++) { - $sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number + $sum += $values[$i] * (int) substr($InumCta, $i, 1); //int to cast result of substr to a number } $key = 11 - $sum % 11; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2af03656a64..734810eb5e4 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"; @@ -69,7 +69,7 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -79,22 +79,22 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][1] = $langs->trans("ContactsAddresses"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; } - if ($object->client==1 || $object->client==2 || $object->client==3) + if ($object->client == 1 || $object->client == 2 || $object->client == 3) { $head[$h][0] = DOL_URL_ROOT.'/comm/card.php?socid='.$object->id; $head[$h][1] = ''; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client==2 || $object->client==3)) $head[$h][1] .= $langs->trans("Prospect"); - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client==3) $head[$h][1] .= ' | '; - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client==1 || $object->client==3)) $head[$h][1] .= $langs->trans("Customer"); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client == 2 || $object->client == 3)) $head[$h][1] .= $langs->trans("Prospect"); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client == 3) $head[$h][1] .= ' | '; + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client == 1 || $object->client == 3)) $head[$h][1] .= $langs->trans("Customer"); $head[$h][2] = 'customer'; $h++; - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $langs->load("products"); // price @@ -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); @@ -129,20 +129,20 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } else { dol_print_error($db); } - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'project'; $h++; } // Tab to link resources - if (! empty($conf->resource->enabled) && ! empty($conf->global->RESOURCE_ON_THIRDPARTIES)) + if (!empty($conf->resource->enabled) && !empty($conf->global->RESOURCE_ON_THIRDPARTIES)) { $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=societe&element_id='.$object->id; $head[$h][1] = $langs->trans("Resources"); @@ -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++; } } @@ -226,23 +226,23 @@ function societe_prepare_head(Societe $object) //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number - $head[$h][0] = DOL_URL_ROOT .'/societe/paymentmodes.php?socid='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $head[$h][1] = $title; - if ($foundonexternalonlinesystem) $head[$h][1].= ' ...'; - elseif ($nbBankAccount > 0) $head[$h][1].= ''.$nbBankAccount.''; + if ($foundonexternalonlinesystem) $head[$h][1] .= ' ...'; + elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.''; $head[$h][2] = 'rib'; $h++; } - if (! empty($conf->website->enabled) && (! empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) + if (!empty($conf->website->enabled) && (!empty($conf->global->WEBSITE_USE_WEBSITE_ACCOUNTS)) && (!empty($user->rights->societe->lire))) { $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as n"; - $sql.= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as n"; + $sql .= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -250,14 +250,14 @@ function societe_prepare_head(Societe $object) while ($i < $num) { $obj = $db->fetch_object($resql); - $nbNote=$obj->nb; + $nbNote = $obj->nb; $i++; } } else { dol_print_error($db); } - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'website'; $h++; } @@ -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++; } } @@ -295,41 +295,41 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/notify/card.php?socid='.$object->id; $head[$h][1] = $langs->trans("Notifications"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'notify'; $h++; } // Notes $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'note'; $h++; // Attached files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -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,"; @@ -1022,41 +1022,41 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".$object->id; - if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); + if ($search_status != '' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); if ($search_poste) $sql .= natural_search('t.poste', $search_poste); if ($search_address) { $sql .= natural_search($searchAddressPhoneDBFields, $search_address); } - if (count($search_roles)>0) { + if (count($search_roles) > 0) { $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } // Add where from extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - if ($sortfield == "t.name") $sql.=" ORDER BY t.lastname $sortorder, t.firstname $sortorder"; - else $sql.= " ORDER BY $sortfield $sortorder"; + if ($sortfield == "t.name") $sql .= " ORDER BY t.lastname $sortorder, t.firstname $sortorder"; + else $sql .= " ORDER BY $sortfield $sortorder"; dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG); $result = $db->query($sql); - if (! $result) dol_print_error($db); + if (!$result) dol_print_error($db); $num = $db->num_rows($result); // Fields title search // -------------------------------------------------------------------- print ''; - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked']) || !empty($arrayfields['sc.'.$key]['checked'])) { - print ''; - foreach($contactstatic->fields as $key => $val) + foreach ($contactstatic->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; - if ($key == 'role') $align.=($align?' ':'').'left'; - if (! empty($arrayfields['sc.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status' || $key == 'statut') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; + if ($key == 'role') $align .= ($align ? ' ' : '').'left'; + if (!empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } } // Extra fields - $extrafieldsobjectkey=$contactstatic->table_element; + $extrafieldsobjectkey = $contactstatic->table_element; 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; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; 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 ''; // 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
'; - if (in_array($key, array('statut'))){ - print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); + print ''; + if (in_array($key, array('statut'))) { + print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); } elseif (in_array($key, array('role'))) { print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } else { @@ -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 ''; @@ -1083,24 +1083,24 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') // Fields title label // -------------------------------------------------------------------- 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, @@ -1531,203 +1531,203 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin 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); - $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 .= ''; if ($donetodo) { - $out.=''; + $out .= ''; } - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; // Action column - $out.=''; - $out.=''; + $out .= ''; + $out .= ''; - $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); } - $out.=getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Owner")); - $out.=getTitleFieldOfList($langs->trans("Type")); - $out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); - $out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); - $out.=''; + $out .= getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Owner")); + $out .= getTitleFieldOfList($langs->trans("Type")); + $out .= getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); + $out .= ''; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - $caction=new CActionComm($db); - $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1); + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); 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']; - $out.=''; + $out .= ''; // Done or todo if ($donetodo) { - $out.=''; + $out .= ''; } // Ref - $out.=''; + $out .= ''; // Author of event - $out.=''; + $out .= ''; // Type - $out.=''; + $labeltype = $actionstatic->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; + $out .= dol_trunc($labeltype, 28); + $out .= ''; // Title - $out.=''; + $out .= ''; // Date - $out.='\n"; + $late = 0; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late = 1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late = 1; + if ($late) $out .= img_warning($langs->trans("Late")).' '; + $out .= "\n"; // Title of event //$out.=''; // Objet lie - $out.=''; + else $out .= ' '; + $out .= ''; // Contact pour cette action if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { - $contactstatic->lastname=$histo[$key]['lastname']; - $contactstatic->firstname=$histo[$key]['firstname']; - $contactstatic->id=$histo[$key]['contact_id']; - $out.=''; + $contactstatic->lastname = $histo[$key]['lastname']; + $contactstatic->firstname = $histo[$key]['firstname']; + $contactstatic->id = $histo[$key]['contact_id']; + $out .= ''; } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { $out .= ''; } else { - $out.=''; + $out .= ''; } // Status - $out.=''; + $out .= ''; // Actions - $out.=''; + $out .= ''; - $out.="\n"; + $out .= "\n"; $i++; } - $out.="
'; - $out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1); - $out.=''; + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1); + $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 .= ''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $out.=$histo[$key]['id']; - $out.=''; + $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); } - $out.=''; + $out .= ''; //$userstatic->id=$histo[$key]['userid']; //$userstatic->login=$histo[$key]['login']; //$out.=$userstatic->getLoginUrl(1); if ($histo[$key]['userid'] > 0) { - $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched - $out.=$userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); + $userstatic->fetch($histo[$key]['userid']); // TODO Introduce a cache on users fetched + $out .= $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } - $out.=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + $out .= ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto); else { - if ($actionstatic->type_code == 'AC_RDV') $out.= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_TEL') $out.= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_FAX') $out.= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_EMAIL') $out.= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actionstatic->type_code == 'AC_INT') $out.= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) $out.= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + if ($actionstatic->type_code == 'AC_RDV') $out .= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_TEL') $out .= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_FAX') $out .= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_EMAIL') $out .= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actionstatic->type_code == 'AC_INT') $out .= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $out .= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } - $labeltype=$actionstatic->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH'; - if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype]; - $out.= dol_trunc($labeltype, 28); - $out.=''; - if (isset($histo[$key]['type']) && $histo[$key]['type']=='action') + $out .= ''; + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['alabel']); + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); //$actionstatic->libelle=$libelle; - $libelle=$histo[$key]['note']; - $actionstatic->id=$histo[$key]['id']; - $out.=dol_trunc($libelle, 120); + $libelle = $histo[$key]['note']; + $actionstatic->id = $histo[$key]['id']; + $out .= dol_trunc($libelle, 120); } - if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') + if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { - $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); - $out.=dol_trunc($libelle, 120); + $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; + $transcode = $langs->trans("Action".$histo[$key]['acode']); + $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= dol_trunc($libelle, 120); } - $out.=''; - $out.=dol_print_date($histo[$key]['datestart'], 'dayhour'); + $out .= ''; + $out .= dol_print_date($histo[$key]['datestart'], 'dayhour'); if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) { - $tmpa=dol_getdate($histo[$key]['datestart'], true); - $tmpb=dol_getdate($histo[$key]['dateend'], true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'], 'hour'); - else $out.='-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); + $tmpa = dol_getdate($histo[$key]['datestart'], true); + $tmpb = dol_getdate($histo[$key]['dateend'], true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out .= '-'.dol_print_date($histo[$key]['dateend'], 'hour'); + else $out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour'); } - $late=0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; - if ($late) $out.=img_warning($langs->trans("Late")).' '; - $out.="'.dol_trunc($histo[$key]['note'], 40).''; + $out .= ''; if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) { - $out.=dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); + $out .= dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1); } - else $out.=' '; - $out.=''.$contactstatic->getNomUrl(1, '', 10).''.$contactstatic->getNomUrl(1, '', 10).''; foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) { @@ -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 "
 
'; - $var=false; + $var = false; // Title print ''; print ''; print ''; print '
'.$langs->trans("DefaultSkin").''; - $url='http://ckeditor.com/addons/skins/all'; + $url = 'http://ckeditor.com/addons/skins/all'; /*print ''; print $langs->trans('DownloadMoreSkins'); print '';*/ @@ -74,7 +74,7 @@ function show_skin($fuser, $edit = 0) print '
'.$langs->trans("ThemeDir").''; - foreach($dirskins as $dirskin) + foreach ($dirskins as $dirskin) { echo '"'.$dirskin.'" '; } @@ -86,22 +86,22 @@ function show_skin($fuser, $edit = 0) 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 ""; // Project status print '"; } @@ -494,12 +494,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t 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 '\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 ''; @@ -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 ''; } @@ -753,43 +753,43 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; - $lastprojectid=0; - $totalforeachline=array(); - $workloadforid=array(); - $lineswithoutlevel0=array(); + $lastprojectid = 0; + $totalforeachline = array(); + $workloadforid = array(); + $lineswithoutlevel0 = array(); - $numlines=count($lines); + $numlines = count($lines); // Create a smaller array with sublevels only to be used later. This increase dramatically performances. if ($parent == 0) // Always and only if at first level { - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; } } if (empty($oldprojectforbreak)) { - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break } //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); - for ($i = 0 ; $i < $numlines ; $i++) + for ($i = 0; $i < $numlines; $i++) { if ($parent == 0) $level = 0; //if ($lines[$i]->fk_task_parent == $parent) //{ // 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); // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { - $lastprojectid=$lines[$i]->fk_project; + $lastprojectid = $lines[$i]->fk_project; if ($preselectedday) { $projectstatic->id = $lines[$i]->fk_project; @@ -800,25 +800,25 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec { if ($preselectedday) { - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week - $workloadforid[$projectstatic->id]=1; + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week + $workloadforid[$projectstatic->id] = 1; } } - $projectstatic->id=$lines[$i]->fk_project; - $projectstatic->ref=$lines[$i]->project_ref; - $projectstatic->title=$lines[$i]->project_label; - $projectstatic->public=$lines[$i]->public; + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->ref = $lines[$i]->project_ref; + $projectstatic->title = $lines[$i]->project_label; + $projectstatic->public = $lines[$i]->public; - $taskstatic->id=$lines[$i]->task_id; - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); - $taskstatic->label=$lines[$i]->task_label; - $taskstatic->date_start=$lines[$i]->date_start; - $taskstatic->date_end=$lines[$i]->date_end; + $taskstatic->id = $lines[$i]->task_id; + $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); + $taskstatic->label = $lines[$i]->task_label; + $taskstatic->date_start = $lines[$i]->date_start; + $taskstatic->date_end = $lines[$i]->date_end; - $thirdpartystatic->id=$lines[$i]->socid; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - $thirdpartystatic->email=$lines[$i]->thirdparty_email; + $thirdpartystatic->id = $lines[$i]->socid; + $thirdpartystatic->name = $lines[$i]->thirdparty_name; + $thirdpartystatic->email = $lines[$i]->thirdparty_email; if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { @@ -862,11 +862,11 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec // Ref print ''; - $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; } // Hour @@ -899,23 +899,23 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print dol_print_date($lines[$i]->timespent_datehour, 'hour'); print ''; - $cssonholiday=''; - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; + $cssonholiday = ''; + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; // Duration - print '
'; - $i=0; - foreach($dirskins as $dir) + $i = 0; + foreach ($dirskins as $dir) { //print $dirroot.$dir;exit; - $dirskin=dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root - $urltheme=dol_buildpath($dir, 1); + $dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root + $urltheme = dol_buildpath($dir, 1); if (is_dir($dirskin)) { - $handle=opendir($dirskin); + $handle = opendir($dirskin); if (is_resource($handle)) { - while (($subdir = readdir($handle))!==false) + while (($subdir = readdir($handle)) !== false) { if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i', $subdir)) + && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) { // Disable not stable themes (dir ends with _exp or _dev) if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue; @@ -110,11 +110,11 @@ function show_skin($fuser, $edit = 0) print '
'; if ($subdir == $selected_theme) { - print ' '.$subdir.''; + print ' '.$subdir.''; } else { - print ' '.$subdir; + print ' '.$subdir; } print '
'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cac2208eb2f..da7d15806f9 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -44,37 +44,37 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') { global $conf, $db, $langs; - dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT)?'null':$conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); + dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT) ? 'null' : $conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); // Default value if setup was not done and/or entry into c_paper_format not defined - $width=210; $height=297; $unit='mm'; + $width = 210; $height = 297; $unit = 'mm'; if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $pdfformat=dol_getDefaultFormat($outputlangs); + $pdfformat = dol_getDefaultFormat($outputlangs); } else { - $pdfformat=$conf->global->MAIN_PDF_FORMAT; + $pdfformat = $conf->global->MAIN_PDF_FORMAT; } - $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; - $sql.=" WHERE code = '".$db->escape($pdfformat)."'"; - $resql=$db->query($sql); + $sql = "SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; + $sql .= " WHERE code = '".$db->escape($pdfformat)."'"; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); if ($obj) { - $width=(int) $obj->width; - $height=(int) $obj->height; - $unit=$obj->unit; + $width = (int) $obj->width; + $height = (int) $obj->height; + $unit = $obj->unit; } } //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit; - return array('width'=>$width,'height'=>$height,'unit'=>$unit); + return array('width'=>$width, 'height'=>$height, 'unit'=>$unit); } /** @@ -90,9 +90,9 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') global $conf; // Define constant for TCPDF - if (! defined('K_TCPDF_EXTERNAL_CONFIG')) + if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { - define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file + define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); dol_mkdir(K_PATH_CACHE); @@ -119,7 +119,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') define('HEAD_MAGNIFICATION', 1.1); define('K_CELL_HEIGHT_RATIO', 1.25); define('K_TITLE_MAGNIFICATION', 1.3); - define('K_SMALL_RATIO', 2/3); + define('K_SMALL_RATIO', 2 / 3); define('K_THAI_TOPCHARS', true); define('K_TCPDF_CALLS_IN_HTML', true); define('K_TCPDF_THROW_EXCEPTION_ERROR', false); @@ -135,14 +135,14 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') //$format=array($arrayformat['width'],$arrayformat['height']); //$metric=$arrayformat['unit']; - $pdfa=false; // PDF-1.3 - if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A + $pdfa = false; // PDF-1.3 + if (!empty($conf->global->PDF_USE_1A)) $pdfa = true; // PDF1/A if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); else $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); // Protection and encryption of pdf - if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) + if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) { /* Permission supported by TCPDF - print : Print the document; @@ -157,20 +157,20 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') */ // For TCPDF, we specify permission we want to block - $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true):array('modify','copy')); // Json format in llx_const + $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const // Password for the end user - $pdfuserpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_USERPASS:''); + $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS : ''); // Password of the owner, created randomly if not defined - $pdfownerpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS:null); + $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS : null); // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit - $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); + $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0); // Array of recipients containing public-key certificates ('c') and permissions ('p'). // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) - $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true):null); // Json format in llx_const + $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true) : null); // Json format in llx_const $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys); } @@ -199,11 +199,11 @@ function pdf_getEncryption($pathoffile) //ob_end_clean(); if (isset($xref['trailer']['encrypt'])) { - $isencrypted = true; // Secured pdf file are currently not supported + $isencrypted = true; // Secured pdf file are currently not supported } if (empty($data)) { - $isencrypted = true; // Object list not found. Possible secured file + $isencrypted = true; // Object list not found. Possible secured file } return $isencrypted; @@ -219,14 +219,14 @@ function pdf_getPDFFont($outputlangs) { global $conf; - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; - $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF + $font = 'Helvetica'; // By default, for FPDI, or ISO language on TCPDF if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) { - if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') + if ($outputlangs->trans('FONTFORPDF') != 'FONTFORPDF') { - $font=$outputlangs->trans('FONTFORPDF'); + $font = $outputlangs->trans('FONTFORPDF'); } } return $font; @@ -242,7 +242,7 @@ function pdf_getPDFFontSize($outputlangs) { global $conf; - $size=10; // By default, for FPDI or ISO language on TCPDF + $size = 10; // By default, for FPDI or ISO language on TCPDF if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 font like DejaVuSans if required (slower) { if ($outputlangs->trans('FONTSIZEFORPDF') != 'FONTSIZEFORPDF') @@ -250,7 +250,7 @@ function pdf_getPDFFontSize($outputlangs) $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); } } - if (! empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; + if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE; return $size; } @@ -266,14 +266,14 @@ function pdf_getPDFFontSize($outputlangs) function pdf_getHeightForLogo($logo, $url = false) { global $conf; - $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); - $maxwidth=130; + $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 22 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $maxwidth = 130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($logo, $url); + $tmp = dol_getImageSize($logo, $url); if ($tmp['height']) { - $width=round($height*$tmp['width']/$tmp['height']); - if ($width > $maxwidth) $height=$height*$maxwidth/$width; + $width = round($height * $tmp['width'] / $tmp['height']); + if ($width > $maxwidth) $height = $height * $maxwidth / $width; } //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; return $height; @@ -307,9 +307,9 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) } else { - for ($page=$start_page; $page <= $end_page; ++$page) { + for ($page = $start_page; $page <= $end_page; ++$page) { $pdf->setPage($page); - $tmpm=$pdf->getMargins(); + $tmpm = $pdf->getMargins(); $tMargin = $tmpm['top']; if ($page == $start_page) { // first page @@ -346,7 +346,7 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali if ($thirdparty instanceof Societe) { $socname .= $thirdparty->name; - if (($includealias || ! empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { + if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { $socname .= "\n".$thirdparty->name_alias; } } elseif ($thirdparty instanceof Contact) { @@ -375,20 +375,20 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { global $conf, $hookmanager; - if ($mode == 'source' && ! is_object($sourcecompany)) return -1; - if ($mode == 'target' && ! is_object($targetcompany)) return -1; + if ($mode == 'source' && !is_object($sourcecompany)) return -1; + if ($mode == 'target' && !is_object($targetcompany)) return -1; - if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); - if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id); + if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state = getState($sourcecompany->state_id); + if (!empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state = getState($targetcompany->state_id); - $reshook=0; + $reshook = 0; $stringaddress = ''; if (is_object($hookmanager)) { $parameters = array('sourcecompany'=>&$sourcecompany, 'targetcompany'=>&$targetcompany, 'targetcontact'=>&$targetcontact, 'outputlangs'=>$outputlangs, 'mode'=>$mode, 'usecontact'=>$usecontact); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $stringaddress.=$hookmanager->resPrint; + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $stringaddress .= $hookmanager->resPrint; } if (empty($reshook)) { @@ -397,64 +397,64 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $withCountry = 0; if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) { // Phone - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); + if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); // Fax - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); + if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); // EMail - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); + if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); // Web - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); + if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); } // Intra VAT - if (! empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) + if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) { - if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); + if ($sourcecompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); } // Professionnal Ids $reg = array(); - if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) + if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) { - $tmp=$outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); + $tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); } - if (! empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof2)) + if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) { - $tmp=$outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); + $tmp = $outputlangs->transcountrynoentities("ProfId2", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); } - if (! empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof3)) + if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) { - $tmp=$outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); + $tmp = $outputlangs->transcountrynoentities("ProfId3", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); } - if (! empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof4)) + if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) { - $tmp=$outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); + $tmp = $outputlangs->transcountrynoentities("ProfId4", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); } - if (! empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof5)) + if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) { - $tmp=$outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); + $tmp = $outputlangs->transcountrynoentities("ProfId5", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); } - if (! empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof6)) + if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) { - $tmp=$outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); + $tmp = $outputlangs->transcountrynoentities("ProfId6", $sourcecompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); } - if (! empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { - $stringaddress.=($stringaddress ? "\n" : '' ).$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; + if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) { + $stringaddress .= ($stringaddress ? "\n" : '').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS; } } @@ -462,10 +462,10 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t { if ($usecontact) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1)); if (!empty($targetcontact->address)) { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); } else { $companytouseforaddress = $targetcompany; @@ -476,73 +476,73 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $companytouseforaddress = $targetcontact->thirdparty; } - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); } // Country if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); } - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); + if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); + if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); + if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); + if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); + if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); } } } else { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); + $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); // Country - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/', $mode)) { // Phone - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/', $mode)) { - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); + if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": "; + if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); + if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .= " / "; + if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); } // Fax - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/', $mode)) { - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); + if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); } // EMail - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/', $mode)) { - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); + if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); } // Web - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) + if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/', $mode)) { - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); + if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); } } } @@ -550,57 +550,57 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t // Intra VAT if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) { - if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); + if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); } // Professionnal Ids - if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) + if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) { - $tmp=$outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); + $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); } - if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) + if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) { - $tmp=$outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); + $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); } - if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) + if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) { - $tmp=$outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); + $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); } - if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) + if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) { - $tmp=$outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); + $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); } - if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) + if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) { - $tmp=$outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); + $tmp = $outputlangs->transcountrynoentities("ProfId5", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); } - if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) + if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) { - $tmp=$outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); - if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp=$reg[1]; - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); + $tmp = $outputlangs->transcountrynoentities("ProfId6", $targetcompany->country_code); + if (preg_match('/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1]; + $stringaddress .= ($stringaddress ? "\n" : '').$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); } // Public note - if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) + if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { - if ($mode == 'source' && ! empty($sourcecompany->note_public)) + if ($mode == 'source' && !empty($sourcecompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($sourcecompany->note_public); } - if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && ! empty($targetcompany->note_public)) + if (($mode == 'target' || preg_match('/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) { - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public); + $stringaddress .= ($stringaddress ? "\n" : '').dol_string_nohtmltag($targetcompany->note_public); } } } @@ -623,11 +623,11 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) global $conf; // Add a background image on document - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image + if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image { - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } @@ -644,8 +644,8 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) function pdf_getSubstitutionArray($outputlangs, $exclude = null, $object = null, $onlykey = 0) { $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude, $object); - $substitutionarray['__FROM_NAME__']='__FROM_NAME__'; - $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__'; + $substitutionarray['__FROM_NAME__'] = '__FROM_NAME__'; + $substitutionarray['__FROM_EMAIL__'] = '__FROM_EMAIL__'; return $substitutionarray; } @@ -666,31 +666,31 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) global $langs, $mysoc, $user; // Print Draft Watermark - if ($unit=='pt') $k=1; - elseif ($unit=='mm') $k=72/25.4; - elseif ($unit=='cm') $k=72/2.54; - elseif ($unit=='in') $k=72; + if ($unit == 'pt') $k = 1; + elseif ($unit == 'mm') $k = 72 / 25.4; + elseif ($unit == 'cm') $k = 72 / 2.54; + elseif ($unit == 'in') $k = 72; // Make substitution - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, null); complete_substitutions_array($substitutionarray, $outputlangs, null); - $text=make_substitutions($text, $substitutionarray, $outputlangs); - $text=$outputlangs->convToOutputCharset($text); + $text = make_substitutions($text, $substitutionarray, $outputlangs); + $text = $outputlangs->convToOutputCharset($text); - $savx=$pdf->getX(); $savy=$pdf->getY(); + $savx = $pdf->getX(); $savy = $pdf->getY(); - $watermark_angle=atan($h/$w)/2; - $watermark_x_pos=0; - $watermark_y_pos=$h/3; - $watermark_x=$w/2; - $watermark_y=$h/3; + $watermark_angle = atan($h / $w) / 2; + $watermark_x_pos = 0; + $watermark_y_pos = $h / 3; + $watermark_x = $w / 2; + $watermark_y = $h / 3; $pdf->SetFont('', 'B', 40); $pdf->SetTextColor(255, 192, 203); //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x*$k, ($h-$watermark_y)*$k, -$watermark_x*$k, -($h-$watermark_y)*$k)); + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k)); //print watermark $pdf->SetXY($watermark_x_pos, $watermark_y_pos); - $pdf->Cell($w-20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); + $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0); //antirotate $pdf->_out('Q'); @@ -716,37 +716,37 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); - $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); if (empty($onlynumber)) { $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; + $cury += 4; } $outputlangs->load("banks"); // Use correct name of bank id according to country - $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; + $bickey = "BICNumber"; + if ($account->getCountryCode() == 'IN') $bickey = "SWIFT"; // Get format of bank account according to its country - $usedetailedbban=$account->useDetailedBBAN(); + $usedetailedbban = $account->useDetailedBBAN(); //$onlynumber=0; $usedetailedbban=1; // For tests if ($usedetailedbban) { - $savcurx=$curx; + $savcurx = $curx; if (empty($onlynumber)) { $pdf->SetFont('', '', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; } if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them @@ -756,12 +756,12 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, // desk = code guichet (FR), used only when $usedetailedbban = 1 // number = account number // key = check control key used only when $usedetailedbban = 1 - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); + if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6); foreach ($account->getFieldsToShow() as $val) { - $pdf->SetXY($curx, $cury+4); + $pdf->SetXY($curx, $cury + 4); $pdf->SetFont('', '', $default_font_size - 3); if ($val == 'BankCode') { @@ -799,54 +799,54 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, } } - $curx=$savcurx; - $cury+=8; + $curx = $savcurx; + $cury += 8; } } else { $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': '.$outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); + $cury += 3; $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': '.$outputlangs->convToOutputCharset($account->number), 0, 'L', 0); + $cury += 3; - if ($diffsizecontent <= 2) $cury+=1; + if ($diffsizecontent <= 2) $cury += 1; } $pdf->SetFont('', '', $default_font_size - $diffsizecontent); - if (empty($onlynumber) && ! empty($account->domiciliation)) + if (empty($onlynumber) && !empty($account->domiciliation)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); + $val = $outputlangs->transnoentities("Residence").': '.$outputlangs->convToOutputCharset($account->domiciliation); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); //$nboflines=dol_nboflines_bis($val,120); //$cury+=($nboflines*3)+2; - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; } - if (! empty($account->proprio)) + if (!empty($account->proprio)) { $pdf->SetXY($curx, $cury); - $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio); + $val = $outputlangs->transnoentities("BankAccountOwner").': '.$outputlangs->convToOutputCharset($account->proprio); $pdf->MultiCell(100, 3, $val, 0, 'L', 0); - $tmpy=$pdf->getStringHeight(100, $val); - $cury+=$tmpy; - $cur+=1; + $tmpy = $pdf->getStringHeight(100, $val); + $cury += $tmpy; + $cur += 1; } - elseif (! $usedetailedbban) $cury+=1; + elseif (!$usedetailedbban) $cury += 1; // Use correct name of bank id according to country $ibankey = FormBank::getIBANLabel($account); - if (! empty($account->iban)) + if (!empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); @@ -856,20 +856,20 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, for ($i = 0; $i < $nbIbanDisplay_temp; $i++) { $ibanDisplay .= $ibanDisplay_temp[$i]; - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; + if ($i % 4 == 3 && $i > 0) $ibanDisplay .= " "; } $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); - $cury+=3; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': '.$ibanDisplay, 0, 'L', 0); + $cury += 3; } - if (! empty($account->bic)) + if (!empty($account->bic)) { $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetXY($curx, $cury); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': '.$outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); } return $pdf->getY(); @@ -892,82 +892,82 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, */ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0) { - global $conf,$user,$mysoc; + global $conf, $user, $mysoc; $outputlangs->load("dict"); - $line=''; + $line = ''; - $dims=$pdf->getPageDimensions(); + $dims = $pdf->getPageDimensions(); // Line of free text - if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) + if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) { - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); // More substitution keys - $substitutionarray['__FROM_NAME__']=$fromcompany->name; - $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; + $substitutionarray['__FROM_NAME__'] = $fromcompany->name; + $substitutionarray['__FROM_EMAIL__'] = $fromcompany->email; complete_substitutions_array($substitutionarray, $outputlangs, $object); - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); // Make a change into HTML code to allow to include images from medias directory. // // become // - $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); + $newfreetext = preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); - $line.=$outputlangs->convToOutputCharset($newfreetext); + $line .= $outputlangs->convToOutputCharset($newfreetext); } // First line of company infos - $line1=""; $line2=""; $line3=""; $line4=""; + $line1 = ""; $line2 = ""; $line3 = ""; $line4 = ""; if ($showdetails == 1 || $showdetails == 3) { // Company name if ($fromcompany->name) { - $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; + $line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; } // Address if ($fromcompany->address) { - $line1.=($line1?" - ":"").str_replace("\n", ", ", $fromcompany->address); + $line1 .= ($line1 ? " - " : "").str_replace("\n", ", ", $fromcompany->address); } // Zip code if ($fromcompany->zip) { - $line1.=($line1?" - ":"").$fromcompany->zip; + $line1 .= ($line1 ? " - " : "").$fromcompany->zip; } // Town if ($fromcompany->town) { - $line1.=($line1?" ":"").$fromcompany->town; + $line1 .= ($line1 ? " " : "").$fromcompany->town; } // Country if ($fromcompany->country) { - $line1.=($line1?", ":"").$fromcompany->country; + $line1 .= ($line1 ? ", " : "").$fromcompany->country; } // Phone if ($fromcompany->phone) { - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; + $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; } // Fax if ($fromcompany->fax) { - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; + $line2 .= ($line2 ? " - " : "").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; } // URL if ($fromcompany->url) { - $line2.=($line2?" - ":"").$fromcompany->url; + $line2 .= ($line2 ? " - " : "").$fromcompany->url; } // Email if ($fromcompany->email) { - $line2.=($line2?" - ":"").$fromcompany->email; + $line2 .= ($line2 ? " - " : "").$fromcompany->email; } } if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) @@ -975,7 +975,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Managers if ($fromcompany->managers) { - $line2.=($line2?" - ":"").$fromcompany->managers; + $line2 .= ($line2 ? " - " : "").$fromcompany->managers; } } @@ -983,90 +983,90 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Juridical status if ($fromcompany->forme_juridique_code) { - $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); + $line3 .= ($line3 ? " - " : "").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital if ($fromcompany->capital) { $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); + else $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); } // Prof Id 1 - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { - $field=$outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); + $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 if ($fromcompany->idprof2) { - $field=$outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); + $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line3 .= ($line3 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); } // Line 4 of company infos // Prof Id 3 if ($fromcompany->idprof3) { - $field=$outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); + $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 if ($fromcompany->idprof4) { - $field=$outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); + $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); } // Prof Id 5 if ($fromcompany->idprof5) { - $field=$outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); + $field = $outputlangs->transcountrynoentities("ProfId5", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); } // Prof Id 6 if ($fromcompany->idprof6) { - $field=$outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); - if (preg_match('/\((.*)\)/i', $field, $reg)) $field=$reg[1]; - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); + $field = $outputlangs->transcountrynoentities("ProfId6", $fromcompany->country_code); + if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; + $line4 .= ($line4 ? " - " : "").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { - $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); + $line4 .= ($line4 ? " - " : "").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); } $pdf->SetFont('', '', 7); $pdf->SetDrawColor(224, 224, 224); // The start of the bottom of this page footer is positioned according to # of lines - $freetextheight=0; + $freetextheight = 0; if ($line) // Free text { //$line="sample text
\nfdsfsdf
\nghfghg
"; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { - $width=200; $align='C'; + $width = 20000; $align = 'L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. + if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { + $width = 200; $align = 'C'; } - $freetextheight=$pdf->getStringHeight($width, $line); + $freetextheight = $pdf->getStringHeight($width, $line); } else { - $freetextheight=pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) + $freetextheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) //print '
'.$freetextheight;exit; } } - $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); - $posy=$marginwithfooter+0; + $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); + $posy = $marginwithfooter + 0; if ($line) // Free text { @@ -1077,50 +1077,50 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } else { - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); } - $posy-=$freetextheight; + $posy -= $freetextheight; } $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); $posy--; - if (! empty($line1)) + if (!empty($line1)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line1, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line2)) + if (!empty($line2)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line2, 0, 'C', 0); - $posy-=3; + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); + $posy -= 3; $pdf->SetFont('', '', 7); } - if (! empty($line3)) + if (!empty($line3)) { $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line3, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); } - if (! empty($line4)) + if (!empty($line4)) { - $posy-=3; + $posy -= 3; $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line4, 0, 'C', 0); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); } // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); + $pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } @@ -1145,17 +1145,17 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size) { $linkedobjects = pdf_getLinkedObjects($object, $outputlangs); - if (! empty($linkedobjects)) + if (!empty($linkedobjects)) { - foreach($linkedobjects as $linkedobject) + foreach ($linkedobjects as $linkedobject) { $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; - if (! empty($linkedobject["date_value"])) + if (!empty($linkedobject["date_value"])) { $reftoshow .= ' / '.$linkedobject["date_value"]; } - $posy+=3; + $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetFont('', '', $default_font_size - 2); $pdf->MultiCell($w, $h, $reftoshow, '', $align); @@ -1185,22 +1185,22 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos { global $db, $conf, $langs, $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); - $action=''; - $reshook=$hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('pdf'=>$pdf, 'i'=>$i, 'outputlangs'=>$outputlangs, 'w'=>$w, 'h'=>$h, 'posx'=>$posx, 'posy'=>$posy, 'hideref'=>$hideref, 'hidedesc'=>$hidedesc, 'issupplierline'=>$issupplierline, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); + $labelproductservice = pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline); //var_dump($labelproductservice);exit; @@ -1212,7 +1212,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos // Description $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true); - $result.=$labelproductservice; + $result .= $labelproductservice; } return $result; } @@ -1232,12 +1232,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; - $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false); - $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:'')); - $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); - $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders - $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); - $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); + $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); + $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); + $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); + $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders + $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''); + $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false); if ($issupplierline) { @@ -1254,9 +1254,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { - $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) + $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). @@ -1264,63 +1264,63 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Set label // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; - $textwasmodified=($label == $prodser->label); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; + $textwasmodified = ($label == $prodser->label); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no - $textwasmodified=false; + $textwasmodified = false; if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { - $textwasmodified=(strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401))!==false); + $textwasmodified = (strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false); } else { - $textwasmodified=($desc == $prodser->description); + $textwasmodified = ($desc == $prodser->description); } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; // Set note - $textwasmodified=($note == $prodser->note); - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; + $textwasmodified = ($note == $prodser->note); + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } // Description short of product line - $libelleproduitservice=$label; + $libelleproduitservice = $label; // Description long of product line - if (! empty($desc) && ($desc != $label)) + if (!empty($desc) && ($desc != $label)) { if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice.='__N__'; + $libelleproduitservice .= '__N__'; } if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) { - $discount=new DiscountAbsolute($db); + $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { @@ -1330,17 +1330,17 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice=$desc."\n".$libelleproduitservice; + $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } else { - $libelleproduitservice.=$desc; + $libelleproduitservice .= $desc; } } } @@ -1348,7 +1348,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // We add ref of product (and supplier ref if defined) $prefix_prodserv = ""; $ref_prodserv = ""; - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { if ($prodser->isService()) { @@ -1367,11 +1367,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) $ref_prodserv = $ref_supplier; elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) - $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; + $ref_prodserv = $ref_supplier.' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; else // Common case { $ref_prodserv = $prodser->ref; // Show local ref - if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); + if ($ref_supplier) $ref_prodserv .= ($prodser->ref ? ' (' : '').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref ? ')' : ''); } } else @@ -1379,72 +1379,72 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $ref_prodserv = $prodser->ref; // Show local ref only } - if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) $ref_prodserv .= " - "; + if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - "; } - if(!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $ref_prodserv = ''.$ref_prodserv.''; } - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; + if (!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { $ref_prodserv = ''.$ref_prodserv.''; } + $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; // Add an additional description for the category products - if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled)) + if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $categstatic=new Categorie($db); + $categstatic = new Categorie($db); // recovering the list of all the categories linked to product - $tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT); + $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT); foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled - $desccateg=$cate->add_description; + $desccateg = $cate->add_description; if ($desccateg) - $libelleproduitservice.='__N__'.$desccateg; + $libelleproduitservice .= '__N__'.$desccateg; } } - if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) + if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) { - $format='day'; + $format = 'day'; $period = ''; // Show duration if exists if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } - if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) + if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; } - if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) + if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; + $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; - if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ - $libelleproduitservice.= ''."__N__ ".$period.''; + if (!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { + $libelleproduitservice .= ''."__N__ ".$period.''; } else { - $libelleproduitservice.="__N__".$period; + $libelleproduitservice .= "__N__".$period; } //print $libelleproduitservice; } if ($dbatch) { - $format='day'; + $format = 'day'; foreach ($dbatch as $detail) { - $dte=array(); - if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); - if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); - if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); - $dte[]=$outputlangs->transnoentitiesnoconv('printQty', $detail->qty); - $libelleproduitservice.= "__N__ ".implode(" - ", $dte); + $dte = array(); + if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); + if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); + if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); + $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->qty); + $libelleproduitservice .= "__N__ ".implode(" - ", $dte); } } // Now we convert \n into br - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/', '
', $libelleproduitservice); - else $libelleproduitservice=preg_replace('/__N__/', "\n", $libelleproduitservice); - $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice, 1); + if (dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace('/__N__/', '
', $libelleproduitservice); + else $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); + $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1); return $libelleproduitservice; } @@ -1462,21 +1462,21 @@ function pdf_getlinenum($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinenum', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->num); + $result .= dol_htmlentitiesbr($object->lines[$i]->num); } return $result; } @@ -1495,21 +1495,21 @@ function pdf_getlineref($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->product_ref); + $result .= dol_htmlentitiesbr($object->lines[$i]->product_ref); } return $result; } @@ -1527,21 +1527,21 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $result.=$hookmanager->resPrint; + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $result .= $hookmanager->resPrint; } if (empty($reshook)) { - $result.=dol_htmlentitiesbr($object->lines[$i]->ref_supplier); + $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier); } return $result; } @@ -1559,47 +1559,47 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager, $mysoc; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { - $tmpresult=''; + $tmpresult = ''; - $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); + $tmpresult .= vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) { if ($object->lines[$i]->total_localtax1 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0); } } if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) { if ($object->lines[$i]->total_localtax2 != 0) { - if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult.='/'; - else $tmpresult=''; - $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); + if (preg_replace('/[\s0%]/', '', $tmpresult)) $tmpresult .= '/'; + else $tmpresult = ''; + $tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0); } } - $tmpresult.= '%'; + $tmpresult .= '%'; - $result.=$tmpresult; + $result .= $tmpresult; } } return $result; @@ -1618,28 +1618,28 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if (empty($hidedetails) || $hidedetails > 1) { $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); - $result.=price($sign * $subprice, 0, $outputlangs); + $result .= price($sign * $subprice, 0, $outputlangs); } } return $result; @@ -1656,27 +1656,27 @@ function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs); } return $result; } @@ -1694,23 +1694,23 @@ function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $result=''; - $reshook=0; + $result = ''; + $reshook = 0; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result = $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty; } return $result; } @@ -1728,23 +1728,23 @@ function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_asked; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked; } return $result; } @@ -1762,23 +1762,23 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; + if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped; } return $result; } @@ -1796,23 +1796,23 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0) { global $hookmanager; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); + if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); } return $result; } @@ -1831,8 +1831,8 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag { global $langs; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1847,14 +1847,14 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag 'special_code' => $special_code ); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); + if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); } return $result; } @@ -1875,23 +1875,23 @@ function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails = 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) $result .= dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs); } return $result; } @@ -1911,8 +1911,8 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (empty($hookmanager)) global $hookmanager; global $conf; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { @@ -1920,9 +1920,9 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) return $hookmanager->resPrint; } if (empty($reshook)) { @@ -1936,10 +1936,10 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } - $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; + $result = ($object->lines[$i]->situation_percent - $prev_progress).'%'; } else - $result = $object->lines[$i]->situation_percent . '%'; + $result = $object->lines[$i]->situation_percent.'%'; } } return $result; @@ -1958,21 +1958,21 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code, 'sign'=>$sign); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { @@ -1993,11 +1993,11 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) $prev_progress = $object->lines[$i]->get_prev_progress($object->id); $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; } - $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); + $result .= price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs); } else { - $result.=price($sign * $total_ht, 0, $outputlangs); + $result .= price($sign * $total_ht, 0, $outputlangs); } } } @@ -2015,31 +2015,31 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) */ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) { - global $hookmanager,$conf; + global $hookmanager, $conf; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; - $reshook=0; - $result=''; + $reshook = 0; + $result = ''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; + if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint; } if (empty($reshook)) { if ($object->lines[$i]->special_code == 3) { - $result.=$outputlangs->transnoentities("Option"); + $result .= $outputlangs->transnoentities("Option"); } - elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); + elseif (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs); } return $result; } @@ -2057,32 +2057,32 @@ function pdf_getTotalQty($object, $type, $outputlangs) { global $hookmanager; - $total=0; - $nblines=count($object->lines); + $total = 0; + $nblines = count($object->lines); // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->special_code != 3) { - if ($type=='all') + if ($type == 'all') { $total += $object->lines[$i]->qty; } - elseif ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); - $action=''; - $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); + $action = ''; + $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks return $hookmanager->resPrint; } - elseif ($type==0 && $object->lines[$i]->product_type == 0) + elseif ($type == 0 && $object->lines[$i]->product_type == 0) { $total += $object->lines[$i]->qty; } - elseif ($type==1 && $object->lines[$i]->product_type == 1) + elseif ($type == 1 && $object->lines[$i]->product_type == 1) { $total += $object->lines[$i]->qty; } @@ -2104,11 +2104,11 @@ function pdf_getLinkedObjects($object, $outputlangs) { global $hookmanager; - $linkedobjects=array(); + $linkedobjects = array(); $object->fetchObjectLinked(); - foreach($object->linkedObjects as $objecttype => $objects) + foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') { @@ -2118,7 +2118,7 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->load('propal'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2129,10 +2129,10 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '') . ($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs); } @@ -2140,7 +2140,7 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'contrat') { $outputlangs->load('contracts'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); @@ -2152,29 +2152,29 @@ function pdf_getLinkedObjects($object, $outputlangs) { $outputlangs->loadLangs(array("orders", "sendings")); - foreach($objects as $x => $elementobject) + foreach ($objects as $x => $elementobject) { - $order=null; + $order = null; // We concat this record info into fields xxx_value. title is overwrote. if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order { $elementobject->fetchObjectLinked(); - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); + if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); } - if (! is_object($order)) + if (!is_object($order)) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); - if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; - $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); + if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / '; + $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); } else { - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); - $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending"); + if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + $linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); //$linkedobjects[$objecttype]['date_value'].= ($elementobject->date_delivery ? ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs) : ''); @@ -2187,9 +2187,9 @@ function pdf_getLinkedObjects($object, $outputlangs) if (is_object($hookmanager)) { $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); - $action=''; - $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; + $action = ''; + $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; } return $linkedobjects; @@ -2206,24 +2206,24 @@ function pdf_getSizeForImage($realpath) { global $conf; - $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); - $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); + $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); + $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $tmp=dol_getImageSize($realpath); + $tmp = dol_getImageSize($realpath); if ($tmp['height']) { - $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight + $width = (int) round($maxheight * $tmp['width'] / $tmp['height']); // I try to use maxheight if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth { - $width=$maxwidth; - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); + $width = $maxwidth; + $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); } else // No pb with maxheight { - $height=$maxheight; + $height = $maxheight; } } - return array('width'=>$width,'height'=>$height); + return array('width'=>$width, 'height'=>$height); } /** @@ -2238,8 +2238,8 @@ function pdf_getSizeForImage($realpath) function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; - $sign=1; - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $sign = 1; + if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); @@ -2249,7 +2249,7 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = if (is_object($hookmanager)) { $special_code = $object->lines[$i]->special_code; - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); $parameters = array( 'i'=>$i, @@ -2258,15 +2258,15 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 'special_code'=>$special_code ); - $action=''; + $action = ''; - if( $hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action)>0) + if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { - return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks + return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks } } - if (empty($hidedetails) || $hidedetails > 1) return $sign * ( ($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht ); + if (empty($hidedetails) || $hidedetails > 1) return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht); } return ''; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 21df0301d49..875705cd8c3 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -48,7 +48,7 @@ function project_prepare_head($object) $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ProjectContact"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'contact'; $h++; @@ -59,13 +59,13 @@ function project_prepare_head($object) $head[$h][1] = $langs->trans("Tasks"); require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $taskstatic=new Task($db); - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); - if ($nbTasks > 0) $head[$h][1].= ''.($nbTasks).''; + $taskstatic = new Task($db); + $nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); + if ($nbTasks > 0) $head[$h][1] .= ''.($nbTasks).''; $head[$h][2] = 'tasks'; $h++; - $nbTimeSpent=0; + $nbTimeSpent = 0; $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; @@ -76,20 +76,20 @@ function project_prepare_head($object) if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent=1; + if ($obj) $nbTimeSpent = 1; } else dol_print_error($db); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1].= '...'; + if ($nbTimeSpent > 0) $head[$h][1] .= '...'; $head[$h][2] = 'timespent'; $h++; } - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) + if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) + || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) + || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) { $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; $head[$h][1] = $langs->trans("ProjectOverview"); @@ -107,23 +107,23 @@ function project_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ' '.$nbNote.''; $head[$h][2] = 'notes'; $h++; } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; @@ -133,17 +133,17 @@ function project_prepare_head($object) $nbComments = $object->getNbComments(); $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1].= ''.$nbComments.''; + if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; $head[$h][2] = 'project_comment'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; - $head[$h][1].= $langs->trans("Events"); - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + $head[$h][1] .= $langs->trans("Events"); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $head[$h][1].= '/'; - $head[$h][1].= $langs->trans("Agenda"); + $head[$h][1] .= '/'; + $head[$h][1] .= $langs->trans("Agenda"); } $head[$h][2] = 'agenda'; $h++; @@ -166,20 +166,20 @@ function task_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'task_task'; $h++; $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TaskRessourceLinks"); - if ($nbContact > 0) $head[$h][1].= ''.$nbContact.''; + if ($nbContact > 0) $head[$h][1] .= ''.$nbContact.''; $head[$h][2] = 'task_contact'; $h++; // Is there timespent ? - $nbTimeSpent=0; + $nbTimeSpent = 0; $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; @@ -189,13 +189,13 @@ function task_prepare_head($object) if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent=1; + if ($obj) $nbTimeSpent = 1; } else dol_print_error($db); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1].= '...'; + if ($nbTimeSpent > 0) $head[$h][1] .= '...'; $head[$h][2] = 'task_time'; $h++; @@ -208,23 +208,23 @@ function task_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; - if(!empty($object->note_private)) $nbNote++; - if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + if (!empty($object->note_private)) $nbNote++; + if (!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1].= ''.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'task_notes'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); - $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); + $filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'task_document'; $h++; @@ -232,9 +232,9 @@ function task_prepare_head($object) if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { $nbComments = $object->getNbComments(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); $head[$h][1] = $langs->trans("CommentLink"); - if ($nbComments > 0) $head[$h][1].= ''.$nbComments.''; + if ($nbComments > 0) $head[$h][1] .= ''.$nbComments.''; $head[$h][2] = 'task_comment'; $h++; } @@ -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 '
"; //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 "'; - $projectstatic->statut=$lines[$i]->projectstatus; + $projectstatic->statut = $lines[$i]->projectstatus; print $projectstatic->getLibStatut(2); 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 '
'; - $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 "
'; - if ($projectidfortotallink > 0) print ''; + if ($projectidfortotallink > 0) print ''; print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); if ($projectidfortotallink > 0) print ''; 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 "   "; @@ -878,20 +878,20 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print dol_print_date($lines[$i]->timespent_datehour, 'day'); print '
'; + print ''; $dayWorkLoad = $lines[$i]->timespent_duration; - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; + $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; - $alreadyspent=''; - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); + $alreadyspent = ''; + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); - $modeinput='hours'; + $modeinput = 'hours'; print ' '; diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index e696be779d0..5c5274aba16 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -21,9 +21,9 @@ * \brief Page setup for modulebuilder module */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -global $conf,$langs,$user, $db; +global $conf, $langs, $user, $db; $langs->loadLangs(array("admin", "other", "modulebuilder")); if (!$user->admin || empty($conf->modulebuilder->enabled)) @@ -35,16 +35,16 @@ $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ -if ($action=="update") +if ($action == "update") { - $res1=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); - $res2=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res3=dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res4=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res5=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res6=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); - $res7=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); - $res8=dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'none'), 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTORPDF', GETPOST('MODULEBUILDER_ASCIIDOCTORPDF', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_NAME', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_NAME', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_EDITOR_URL', GETPOST('MODULEBUILDER_SPECIFIC_EDITOR_URL', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res6 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_FAMILY', GETPOST('MODULEBUILDER_SPECIFIC_FAMILY', 'nohtml'), 'chaine', 0, '', $conf->entity); + $res7 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_AUTHOR', GETPOST('MODULEBUILDER_SPECIFIC_AUTHOR', 'html'), 'chaine', 0, '', $conf->entity); + $res8 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_VERSION', GETPOST('MODULEBUILDER_SPECIFIC_VERSION', 'nohtml'), 'chaine', 0, '', $conf->entity); if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); $db->rollback(); @@ -63,7 +63,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { $values = implode(',', $values); if (dolibarr_set_const($db, $code, $values, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: " . $_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -73,7 +73,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) { if (preg_match('/del_(.*)/', $action, $reg)) { $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: " . $_SERVER["PHP_SELF"]); + Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); @@ -89,27 +89,27 @@ $form = new Form($db); llxHeader('', $langs->trans("ModulebuilderSetup")); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = ''.$langs->trans("BackToModuleList").''; print '
'; print ''; print ''; -print load_fiche_titre($langs->trans("ModuleSetup") . ' ' . $langs->trans('Modulebuilder'), $linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('Modulebuilder'), $linkback); if (GETPOST('withtab', 'alpha')) { dol_fiche_head($head, 'modulebuilder', '', -1); } -print '' . $langs->trans("ModuleBuilderDesc") . "
\n"; +print ''.$langs->trans("ModuleBuilderDesc")."
\n"; print '
'; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print "\n"; @@ -118,49 +118,49 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is use cas of this 2 options ? print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; @@ -168,14 +168,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; 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 ''; $stringtoshow .= '
'; // hideobject is to start hidden -$stringtoshow .= '
'; -$stringtoshow .= ''; +$stringtoshow .= ''; +$stringtoshow .= ''; $stringtoshow .= ''; -$stringtoshow .= $langs->trans("Year") . ' '; -$stringtoshow .= ''; +$stringtoshow .= $langs->trans("Year").' '; +$stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= '
'; print '
'; print '
' . $langs->trans("Key") . '' . $langs->trans("Value") . ''.$langs->trans("Key").''.$langs->trans("Value").'
' . $langs->trans("UseAboutPage") . ''.$langs->trans("UseAboutPage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MODULEBUILDER_USE_ABOUT'); } else { if (empty($conf->global->MODULEBUILDER_USE_ABOUT)) { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { - print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + print ''.img_picto($langs->trans("Enabled"), 'on').''; } } print '
' . $langs->trans("UseSpecificEditorName") . ''.$langs->trans("UseSpecificEditorName").''; print ''; print '
' . $langs->trans("UseSpecificEditorURL") . ''.$langs->trans("UseSpecificEditorURL").''; print ''; print '
' . $langs->trans("UseSpecificFamily") . ''.$langs->trans("UseSpecificFamily").''; print ''; print '
' . $langs->trans("UseSpecificAuthor") . ''.$langs->trans("UseSpecificAuthor").''; print ''; print '
' . $langs->trans("UseSpecificVersion") . ''.$langs->trans("UseSpecificVersion").''; print ''; print '
' . $langs->trans("UseSpecificReadme") . ''.$langs->trans("UseSpecificReadme").''; print ''; print '
' . $langs->trans("AsciiToHtmlConverter") . ''.$langs->trans("AsciiToHtmlConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoc, asciidoctor'; @@ -183,7 +183,7 @@ print '
' . $langs->trans("AsciiToPdfConverter") . ''.$langs->trans("AsciiToPdfConverter").''; print ''; print ' '.$langs->trans("Example").': asciidoctor-pdf'; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 6c5f44fc732..56e7865a346 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -23,23 +23,23 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); global $langs, $user; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; //require_once "../class/myclass.class.php"; @@ -47,15 +47,15 @@ require_once '../lib/mymodule.lib.php'; $langs->loadLangs(array("admin", "mymodule@mymodule")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -79,7 +79,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); @@ -100,12 +100,12 @@ if ($action == 'edit') print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '
'; @@ -118,17 +118,17 @@ if ($action == 'edit') } else { - if (! empty($arrayofparameters)) + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '' . $conf->global->$key . '
'.$conf->global->$key.'
'; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index f8161cb2917..0f71b0ceabf 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -99,19 +99,19 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) } } - if (! $testdate) { + if (!$testdate) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors'); } if ($titre && $testdate) { - if (! empty($creation_sondage_date)) + if (!empty($creation_sondage_date)) { header("Location: choix_date.php"); exit(); } - if (! empty($creation_sondage_autre)) + if (!empty($creation_sondage_autre)) { header("Location: choix_autre.php"); exit(); @@ -128,8 +128,8 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) $form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss); print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)'); @@ -142,22 +142,22 @@ dol_fiche_head(); // Affichage des différents champs textes a remplir print ''."\n"; -print ''."\n"; -if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) +print ''."\n"; +if (!$_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); } print ''."\n"; -print ''."\n"; print ''."\n"; -print ''."\n"; print '
'. $langs->trans("PollTitle") .'
'.$langs->trans("PollTitle").'
'. $langs->trans("Description") .''; -$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); +print '
'.$langs->trans("Description").''; +$doleditor = new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); print '
'. $langs->trans("ExpireDate") .''; +print '
'.$langs->trans("ExpireDate").''; -print $form->selectDate($champdatefin?$champdatefin:-1, 'champdatefin', '', '', '', "add", 1, 0); +print $form->selectDate($champdatefin ? $champdatefin : -1, 'champdatefin', '', '', '', "add", 1, 0); print '
'."\n"; @@ -173,16 +173,16 @@ print '
'."\n"; // Check or not -if ($_SESSION["mailsonde"]) $cochemail="checked"; +if ($_SESSION["mailsonde"]) $cochemail = "checked"; -print ' '. $langs->trans("ToReceiveEMailForEachVote") .'
'."\n"; +print ' '.$langs->trans("ToReceiveEMailForEachVote").'
'."\n"; if ($_SESSION['allow_comments']) $allow_comments = 'checked'; -if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked':''; +if (isset($_POST['allow_comments'])) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; print ' '.$langs->trans('CanComment').'
'."\n"; if ($_SESSION['allow_spy']) $allow_spy = 'checked'; -if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked':''; +if (isset($_POST['allow_spy'])) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; if (GETPOST('choix_sondage')) @@ -190,15 +190,15 @@ if (GETPOST('choix_sondage')) if (GETPOST('choix_sondage') == 'date') print ''; else print ''; print ''; - print '
trans("TypeDate"):$langs->trans("TypeClassic")).')">'; + print '
trans("TypeDate") : $langs->trans("TypeClassic")).')">'; } else { // Show image to selecte between date survey or other survey print '
'."\n"; - print ' '."\n"; + print ' '."\n"; print ''."\n"; - print ' '."\n"; + print ' '."\n"; print ''."\n"; print '
'. $langs->trans("CreateSurveyDate") .'
'.$langs->trans("CreateSurveyDate").'
'. $langs->trans("CreateSurveyStandard") .'
'.$langs->trans("CreateSurveyStandard").'
'."\n"; } diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index cea14170602..11c2e91b233 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $search_project_user = GETPOST('search_project_user', 'int'); -$mine = GETPOST('mode', 'aZ09')=='mine' ? 1 : 0; +$mine = GETPOST('mode', 'aZ09') == 'mine' ? 1 : 0; if ($search_project_user == $user->id) $mine = 1; // Security check -$socid=0; -if ($user->socid > 0) $socid=$user->socid; +$socid = 0; +if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'projet', $projectid); if (!$user->rights->projet->lire) accessforbidden(); @@ -54,36 +54,36 @@ $langs->load("projects"); */ $now = dol_now(); -$tmp=dol_getdate($now); -$day=$tmp['mday']; -$month=$tmp['mon']; -$year=$tmp['year']; +$tmp = dol_getdate($now); +$day = $tmp['mday']; +$month = $tmp['mon']; +$year = $tmp['year']; -$projectstatic=new Project($db); -$taskstatic=new Task($db); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project -$taskstatic=new Task($db); -$tasktmp=new Task($db); +$projectstatic = new Project($db); +$taskstatic = new Task($db); +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project +$taskstatic = new Task($db); +$tasktmp = new Task($db); -$title=$langs->trans("Activities"); +$title = $langs->trans("Activities"); //if ($mine) $title=$langs->trans("MyActivities"); llxHeader("", $title); // Title for combo list see all projects -$titleall=$langs->trans("AllAllowedProjects"); -if (! empty($user->rights->projet->all->lire) && ! $socid) $titleall=$langs->trans("AllProjects"); -else $titleall=$langs->trans("AllAllowedProjects").'

'; +$titleall = $langs->trans("AllAllowedProjects"); +if (!empty($user->rights->projet->all->lire) && !$socid) $titleall = $langs->trans("AllProjects"); +else $titleall = $langs->trans("AllAllowedProjects").'

'; -$morehtml=''; -$morehtml.=''; -$morehtml.=''; -$morehtml.=''; +$morehtml = ''; +$morehtml .= ''; +$morehtml .= ''; +$morehtml .= ''; print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'project', 0, $morehtml); //print load_fiche_titre($title, '', 'project'); @@ -91,7 +91,7 @@ print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, -1, 'proje if ($mine) print $langs->trans("MyTasksDesc").'

'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksDesc").'

'; + if ($user->rights->projet->all->lire && !$socid) print $langs->trans("TasksDesc").'

'; else print $langs->trans("TasksPublicDesc").'

'; } @@ -99,12 +99,12 @@ else print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search project - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { - $listofsearchfields['search_task']=array('text'=>'Task'); + $listofsearchfields['search_task'] = array('text'=>'Task'); } if (count($listofsearchfields)) @@ -113,8 +113,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
'; print ''; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -140,30 +140,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -197,30 +197,30 @@ print ''; print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity = ".$conf->entity; -$sql.= " AND tt.fk_task = t.rowid"; -$sql.= " AND tt.fk_user = ".$user->id; -$sql.= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; -$sql.= " AND p.rowid in (".$projectsListId.")"; -$sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity = ".$conf->entity; +$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_user = ".$user->id; +$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; +$sql .= " AND p.rowid in (".$projectsListId.")"; +$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { - $total=0; + $total = 0; while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -304,7 +304,7 @@ if ($db->type != 'pgsql') */ /* Affichage de la liste des projets du mois */ -if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) +if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) { print '
'; print '
'.$langs->trans("Search").'
'.$langs->trans("Time").'
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').''.$langs->trans("Time").'
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
'; @@ -314,27 +314,27 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -355,7 +355,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) } /* Affichage de la liste des projets de l'annee */ -if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) +if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) { print '
'; print '
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
'; @@ -365,28 +365,28 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print "\n"; $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; - $sql.= " WHERE t.fk_projet = p.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND tt.fk_task = t.rowid"; - $sql.= " AND tt.fk_user = ".$user->id; - $sql.= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; - $sql.= " AND p.rowid in (".$projectsListId.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= " WHERE t.fk_projet = p.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_user = ".$user->id; + $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; + $sql .= " AND p.rowid in (".$projectsListId.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { while ($row = $db->fetch_object($resql)) { print ''; print ''; print ''; @@ -406,72 +406,72 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; } -if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) +if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA)) { // Get id of types of contacts for projects (This list never contains a lot of elements) - $listofprojectcontacttype=array(); + $listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$projectstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found // Get id of types of contacts for tasks (This list never contains a lot of elements) - $listoftaskcontacttype=array(); + $listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE ctc.element = '" . $taskstatic->element . "'"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " WHERE ctc.element = '".$taskstatic->element."'"; + $sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listoftaskcontacttype[$obj->rowid]=$obj->code; + $listoftaskcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); - if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found + if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found // Tasks for all resources of all opened projects and time spent for each task/resource // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list - $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); + $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,"; - $sql.= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; + $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; if ($mine) { - $sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; } - $sql.= " WHERE p.entity IN (".getEntity('project').")"; - if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on + $sql .= " WHERE p.entity IN (".getEntity('project').")"; + if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on if ($mine) // this may duplicate record if we are contact twice { - $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; + $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; } - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - $sql.= " AND p.fk_statut=1"; - $sql.= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; - $sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; - $sql.= $db->plimit($max+1); // We want more to know if we have more than limit + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND p.fk_statut=1"; + $sql .= " GROUP BY p.ref, p.title, p.rowid, p.fk_statut, p.fk_opp_status, p.public, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee"; + $sql .= " ORDER BY t.dateo desc, t.rowid desc, t.datee"; + $sql .= $db->plimit($max + 1); // We want more to know if we have more than limit dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG); $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -483,7 +483,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; //print ''; print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print ''; print ''; print ''; print ''; @@ -511,11 +511,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S $taskstatic->dateo = $db->jdate($obj->dateo); $taskstatic->datee = $db->jdate($obj->datee); - $username=''; + $username = ''; if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user { - $result=$userstatic->fetch($obj->userid); - if (! $result) $userstatic->id=0; + $result = $userstatic->fetch($obj->userid); + if (!$result) $userstatic->id = 0; } if ($userstatic->id) $username = $userstatic->getNomUrl(0, 0); @@ -524,7 +524,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print ''; } print ''; print ''; print ''; print "\n"; @@ -572,8 +572,8 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S if ($num > $max) { - $colspan=6; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; + $colspan = 6; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++; print ''; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 51af2f2b14d..493978f738e 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -36,57 +36,57 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies')); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm', 'aZ09'); -$status=GETPOST('status', 'int'); -$opp_status=GETPOST('opp_status', 'int'); -$opp_percent=price2num(GETPOST('opp_percent', 'alpha')); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'aZ09'); +$status = GETPOST('status', 'int'); +$opp_status = GETPOST('opp_status', 'int'); +$opp_percent = price2num(GETPOST('opp_percent', 'alpha')); -if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && ! $_POST["cancel"])) accessforbidden(); +if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !$_POST["cancel"])) accessforbidden(); -$mine = GETPOST('mode')=='mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('projectcard','globalcard')); +$hookmanager->initHooks(array('projectcard', 'globalcard')); $object = new Project($db); $extrafields = new ExtraFields($db); // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can't use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref. -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database + $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); - $id=$object->id; + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + $id = $object->id; } } // Security check -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $object->id, 'projet&project'); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$date_start=dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); -$date_end=dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int')); +$date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int')); /* * Actions */ -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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)) @@ -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,26 +189,26 @@ 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(); - if (! empty($backtopage)) + if (!empty($backtopage)) { - $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - $backtopage = $backtopage.'&projectid='.$object->id; // Old method + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + $backtopage = $backtopage.'&projectid='.$object->id; // Old method header("Location: ".$backtopage); exit; } @@ -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 '
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - $projectstatic->public=$row->public; + $projectstatic->id = $row->rowid; + $projectstatic->ref = $row->ref; + $projectstatic->title = $row->title; + $projectstatic->public = $row->public; print $projectstatic->getNomUrl(1, '', 1); print ''.convertSecondToTime($row->nb, 'allhourmin').'
'.$langs->trans('TaskRessourceLinks').''.$langs->trans('OpenedProjects').''.$langs->trans('OpportunityStatus').''.$langs->trans('OpportunityStatus').''.$langs->trans('Task').''.$langs->trans('DateStart').''.$langs->trans('DateEnd').''; print $projectstatic->getNomUrl(1, '', 0, '', '
'); print '
'; $code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code'); @@ -532,7 +532,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { $tasktmp->id = $obj->taskid; $tasktmp->ref = $obj->ref; @@ -552,18 +552,18 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S print convertSecondToTime($obj->timespent, 'allhourmin'); print ''; - if (! empty($obj->taskid)) + if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { - $percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%'; + $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload).'%'; } } print $percentcompletion; print ''; - print ($obj->taskid>0)?$obj->progress.'%':''; + print ($obj->taskid > 0) ? $obj->progress.'%' : ''; print '
'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'
'; - $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 ''; } @@ -612,46 +612,46 @@ if ($action == 'create' && $user->rights->projet->creer) // Visibility 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); @@ -780,16 +780,16 @@ elseif ($object->id > 0) print ''; print ''; - $head=project_prepare_head($object); + $head = project_prepare_head($object); if ($action == 'edit' && $userWrite > 0) { - dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public ? 'projectpub' : 'project')); 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,20 +584,20 @@ 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; - if (! GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; 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 "
'; // Ref - $suggestedref=$object->ref; + $suggestedref = $object->ref; print ''; 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)); @@ -803,9 +803,9 @@ elseif ($object->id > 0) // Status 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 "
'; -print ''; +print ''; print ''; @@ -274,26 +274,26 @@ $max = 10; $sql = "SELECT t.rowid, t.ref, t.track_id, t.datec, t.subject, t.type_code, t.category_code, t.severity_code, t.fk_statut, t.progress,"; $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label"; -$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 .= " 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"; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql .= ' WHERE t.entity IN (' . getEntity('ticket') . ')'; +$sql .= ' WHERE t.entity IN ('.getEntity('ticket').')'; $sql .= " AND t.fk_statut=0"; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; + $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($user->socid > 0) { - $sql .= " AND t.fk_soc='" . $user->socid . "'"; + $sql .= " AND t.fk_soc='".$user->socid."'"; } else { // Restricted to assigned user only if ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && !$user->rights->ticket->manage) { - $sql .= " AND t.fk_user_assign=" . $user->id; + $sql .= " AND t.fk_user_assign=".$user->id; } } $sql .= $db->order("t.datec", "DESC"); @@ -310,7 +310,7 @@ if ($result) { print '
'; print '
' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '
'.$langs->trans("Statistics").' '.img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"').'
'; print $stringtoshow; // don't display graph if no series -if (! empty($dataseries) && count($dataseries) > 1) { - $totalnb=0; +if (!empty($dataseries) && count($dataseries) > 1) { + $totalnb = 0; foreach ($dataseries as $key => $value) { $totalnb += $value['data']; } @@ -252,7 +252,7 @@ if (! empty($dataseries) && count($dataseries) > 1) { //$px1->SetTitle($langs->trans("TicketStatByStatus")); $px1->draw($filenamenb, $fileurlnb); - print $px1->show($totalnb?0:1); + print $px1->show($totalnb ? 0 : 1); } } print '
'; - print ''; + print ''; print ''; print ''; if ($num > 0) { @@ -338,7 +338,7 @@ if ($result) { // Subject print '\n"; // Type @@ -366,7 +366,7 @@ if ($result) { $db->free(); } else { - print ''; + print ''; } print "
' . $transRecordedType . '
'.$transRecordedType.''.$langs->trans("FullList").'
'; - print '' . dol_trunc($objp->subject, 30) . ''; + print ''.dol_trunc($objp->subject, 30).''; print "
' . $langs->trans('NoUnreadTicketsFound') . '
'.$langs->trans('NoUnreadTicketsFound').'
"; diff --git a/htdocs/zapier/admin/setup.php b/htdocs/zapier/admin/setup.php index 0754f75bb3c..167da89cfe9 100644 --- a/htdocs/zapier/admin/setup.php +++ b/htdocs/zapier/admin/setup.php @@ -26,22 +26,22 @@ require '../../main.inc.php'; // Libraries -require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/zapier.lib.php'; // Translations $langs->loadLangs(array("admin", "zapier@zapier")); // Access control -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters=array( - 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200','enabled'=>1), - 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500','enabled'=>1) +$arrayofparameters = array( + 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), + 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) ); @@ -61,7 +61,7 @@ $page_name = "ZapierSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier@zapier'); @@ -81,10 +81,10 @@ if ($action == 'edit') { print ''; print ''; - foreach($arrayofparameters as $key => $val) { + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; @@ -95,14 +95,14 @@ if ($action == 'edit') { print ''; print '
'; } else { - if (! empty($arrayofparameters)) { + if (!empty($arrayofparameters)) { print ''; print ''; - foreach($arrayofparameters as $key => $val) { + foreach ($arrayofparameters as $key => $val) { print ''; + print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '' . $conf->global->$key . '
'.$conf->global->$key.'
';